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.
Files changed (97) hide show
  1. pytecplot-1.5.2.dist-info/LICENSE.html +77 -0
  2. pytecplot-1.5.2.dist-info/METADATA +508 -0
  3. pytecplot-1.5.2.dist-info/RECORD +97 -0
  4. pytecplot-1.5.2.dist-info/WHEEL +5 -0
  5. pytecplot-1.5.2.dist-info/top_level.txt +1 -0
  6. tecplot/__init__.py +94 -0
  7. tecplot/annotation/__init__.py +7 -0
  8. tecplot/annotation/annotation.py +223 -0
  9. tecplot/annotation/geometry.py +369 -0
  10. tecplot/annotation/georeference.py +33 -0
  11. tecplot/annotation/image.py +185 -0
  12. tecplot/annotation/iter.py +105 -0
  13. tecplot/annotation/polyline.py +381 -0
  14. tecplot/annotation/text.py +744 -0
  15. tecplot/constant.py +401 -0
  16. tecplot/data/__init__.py +34 -0
  17. tecplot/data/array.py +645 -0
  18. tecplot/data/create.py +1 -0
  19. tecplot/data/dataset.py +1809 -0
  20. tecplot/data/extract.py +544 -0
  21. tecplot/data/face_neighbors.py +494 -0
  22. tecplot/data/facemap.py +814 -0
  23. tecplot/data/load.py +2075 -0
  24. tecplot/data/nodemap.py +577 -0
  25. tecplot/data/operate.py +928 -0
  26. tecplot/data/query.py +334 -0
  27. tecplot/data/save.py +343 -0
  28. tecplot/data/variable.py +280 -0
  29. tecplot/data/zone.py +841 -0
  30. tecplot/exception.py +201 -0
  31. tecplot/export/__init__.py +13 -0
  32. tecplot/export/animation.py +521 -0
  33. tecplot/export/export_setup.py +318 -0
  34. tecplot/export/image.py +577 -0
  35. tecplot/export/print_setup.py +218 -0
  36. tecplot/export/time_animation.py +607 -0
  37. tecplot/extension/__init__.py +14 -0
  38. tecplot/extension/ipython.py +68 -0
  39. tecplot/layout/__init__.py +20 -0
  40. tecplot/layout/frame.py +1285 -0
  41. tecplot/layout/layout.py +488 -0
  42. tecplot/layout/page.py +541 -0
  43. tecplot/legend/__init__.py +4 -0
  44. tecplot/legend/contour_legend.py +516 -0
  45. tecplot/legend/legend.py +141 -0
  46. tecplot/legend/line_legend.py +66 -0
  47. tecplot/legend/rgb_coloring_legend.py +291 -0
  48. tecplot/legend/scatter_legend.py +136 -0
  49. tecplot/macro.py +339 -0
  50. tecplot/plot/__init__.py +62 -0
  51. tecplot/plot/axes.py +881 -0
  52. tecplot/plot/axis.py +1350 -0
  53. tecplot/plot/blanking.py +584 -0
  54. tecplot/plot/contour.py +1302 -0
  55. tecplot/plot/effects.py +162 -0
  56. tecplot/plot/fieldmap.py +2159 -0
  57. tecplot/plot/grid.py +758 -0
  58. tecplot/plot/isosurface.py +1167 -0
  59. tecplot/plot/labels.py +338 -0
  60. tecplot/plot/linemap.py +1905 -0
  61. tecplot/plot/linking.py +489 -0
  62. tecplot/plot/plot.py +1791 -0
  63. tecplot/plot/rgb_coloring.py +281 -0
  64. tecplot/plot/scatter.py +396 -0
  65. tecplot/plot/slice.py +1544 -0
  66. tecplot/plot/streamtrace.py +1949 -0
  67. tecplot/plot/symbol.py +567 -0
  68. tecplot/plot/ticks.py +666 -0
  69. tecplot/plot/title.py +380 -0
  70. tecplot/plot/vector.py +679 -0
  71. tecplot/plot/view.py +868 -0
  72. tecplot/session/__init__.py +112 -0
  73. tecplot/session/aux_data.py +276 -0
  74. tecplot/session/config.py +92 -0
  75. tecplot/session/session.py +425 -0
  76. tecplot/session/state_changed.py +225 -0
  77. tecplot/session/style.py +504 -0
  78. tecplot/tecutil/__init__.py +16 -0
  79. tecplot/tecutil/arglist.py +230 -0
  80. tecplot/tecutil/captured_output.py +177 -0
  81. tecplot/tecutil/constant.py +1312 -0
  82. tecplot/tecutil/index_set.py +118 -0
  83. tecplot/tecutil/lock.py +36 -0
  84. tecplot/tecutil/message_pb2.py +39 -0
  85. tecplot/tecutil/preamble.py +54 -0
  86. tecplot/tecutil/stringlist.py +114 -0
  87. tecplot/tecutil/sv.py +1662 -0
  88. tecplot/tecutil/tecutil.py +12402 -0
  89. tecplot/tecutil/tecutil_client.py +627 -0
  90. tecplot/tecutil/tecutil_connector.py +937 -0
  91. tecplot/tecutil/tecutil_rpc.py +6845 -0
  92. tecplot/tecutil/util.py +332 -0
  93. tecplot/text/__init__.py +3 -0
  94. tecplot/text/font.py +224 -0
  95. tecplot/text/label_format.py +374 -0
  96. tecplot/text/textbox.py +106 -0
  97. tecplot/version.py +41 -0
@@ -0,0 +1,425 @@
1
+ import atexit
2
+ import contextlib
3
+ import datetime
4
+ import logging
5
+ import platform
6
+ import textwrap
7
+
8
+ from ..tecutil import _tecutil_connector
9
+ from ..exception import *
10
+ from .state_changed import _emit_state_changes
11
+
12
+
13
+ log = logging.getLogger(__name__)
14
+
15
+
16
+ def stop():
17
+ """Releases the |Tecplot License| and shuts down |Tecplot Engine|.
18
+
19
+ This shuts down the |Tecplot Engine| and releases the |Tecplot License|.
20
+ Call this function when your script is finished using |PyTecplot|.
21
+ Calling this function is not required. If you do not call this function,
22
+ it will be called automatically when your script exists. However, the
23
+ |Tecplot License| will not be released until you call this function.
24
+
25
+ This method is silently ignored when connected to a running instance of
26
+ |Tecplot 360| (see `tecplot.session.connect()`).
27
+
28
+ Note that stop() may only be called once during the life of a Python
29
+ session. If it has already been called, subsequent calls do nothing::
30
+
31
+ >>> # Shutdown tecplot and release license
32
+ >>> tecplot.session.stop()
33
+
34
+ See also: `tecplot.session.acquire_license()`,
35
+ `tecplot.session.release_license()`.
36
+ """
37
+ _tecutil_connector.stop()
38
+
39
+
40
+ def acquire_license():
41
+ """Attempts to acquire the |Tecplot License|
42
+
43
+ Call this function to attempt to acquire a |Tecplot License|. If
44
+ |Tecplot Engine| is not started, this function will start the
45
+ |Tecplot Engine| before attempting to acquire a license.
46
+
47
+ This function can be used to re-acquire a license that was released with
48
+ `tecplot.session.release_license`.
49
+
50
+ If the |Tecplot Engine| is currently running, and a
51
+ |Tecplot License| has already been acquired, this function has no effect.
52
+
53
+ Licenses may be acquired and released any number of times during the same
54
+ Python session.
55
+
56
+ Raises `TecplotLicenseError` if a valid license could not be acquired.
57
+
58
+ .. note:: Warning emitted when close to expiration date.
59
+
60
+ A warning is emitted using Python's built-in `warnings` module if you
61
+ are within 30 days of your TecPLUS subscription expiration date. The
62
+ message will look like this:
63
+
64
+ .. code-block:: shell
65
+
66
+ $ python
67
+ >>> import tecplot
68
+ >>> tecplot.session.acquire_license()
69
+ /path/to/tecutil_connector.py:458: UserWarning:
70
+ Your Tecplot software maintenance subscription
71
+ (TecPLUS) will expire in **13 days**, after which you
72
+ will no longer be able to use PyTecplot. Contact
73
+ sales@tecplot.com to renew your TecPLUS subscription.
74
+
75
+ warn(warning_msg)
76
+
77
+ These warnings can be suppressed by using the ``-W ignore`` option when
78
+ invoking the python interpreter:
79
+
80
+ .. code-block:: shell
81
+
82
+ $ python -W ignore
83
+ >>> import tecplot
84
+ >>> tecplot.session.acquire_license()
85
+
86
+ See also: `tecplot.session.release_license()`
87
+
88
+ Example::
89
+
90
+ >>> import tecplot
91
+ >>> # Do useful things
92
+ >>> tecplot.session.release_license()
93
+ >>> # Do time-consuming things not related to |PyTecplot|
94
+ >>> tecplot.session.acquire_license() # re-acquire the license
95
+ >>> # Do useful |PyTecplot| related things.
96
+ """
97
+ _tecutil_connector.acquire_license()
98
+
99
+
100
+ def release_license():
101
+ """Attempts to release the |Tecplot License|
102
+
103
+ Call this to release a |Tecplot License|. Normally you do not need to call
104
+ this function since `tecplot.session.stop()` will call it for you when your
105
+ script exists and the Python interpreter is unloaded.
106
+
107
+ This function can be used to release a license so that the license is
108
+ available to other instances of |Tecplot 360|.
109
+
110
+ If the |Tecplot License| has already been released, this function has
111
+ no effect.
112
+
113
+ Licenses may be acquired and released any number of times during the same
114
+ Python session. This method is silently ignored when connected to a running
115
+ instance of |Tecplot 360| (see `tecplot.session.connect()`).
116
+
117
+ See also: `tecplot.session.acquire_license()`
118
+
119
+ Example usage::
120
+
121
+ >>> import tecplot
122
+ >>> # Do useful things
123
+ >>> tecplot.session.release_license()
124
+ >>> # Do time-consuming things not related to |PyTecplot|
125
+ >>> tecplot.session.acquire_license() # re-acquire the license
126
+ >>> # Do useful |PyTecplot| related things.
127
+ """
128
+ _tecutil_connector.release_license()
129
+
130
+
131
+ def start_roaming(days):
132
+ """Check out a roaming license.
133
+
134
+ Parameters:
135
+ days (`int`): Number of days to roam.
136
+
137
+ This will acquire a PyTecplot license and then attempt to set it up for
138
+ roaming. The maximum number of days one may roam is typically 90. This
139
+ function can be called in an interactive terminal
140
+ and will affect all subsequent uses of PyTecplot on the local machine.
141
+ Do not forget to `release <tecplot.session.stop_roaming>`
142
+ the roaming license to the server if you are finished roaming before the
143
+ expiration date.
144
+
145
+ See also: `tecplot.session.stop_roaming()`
146
+
147
+ Example usage where ``YYYY-MM-DD`` will be the date 10 days from when this
148
+ code was executed::
149
+
150
+ >>> tecplot.session.start_roaming(10)
151
+ You have successfully checked out a roaming license of
152
+ PyTecplot. This will be valid for 10 days until
153
+ midnight of YYY-MM-DD.
154
+ >>> tecplot.session.stop_roaming()
155
+ Your PyTecplot roaming license has been checked in.
156
+ """
157
+ if _tecutil_connector.connected:
158
+ msg = textwrap.dedent('''\
159
+ Roaming PyTecplot is not available when connected.
160
+ To roam PyTecplot, first disconnect with
161
+ tecplot.session.disconnect(). Roaming with Tecplot 360
162
+ is available under Help -> License Roaming.
163
+ ''')
164
+ raise TecplotLogicError(msg)
165
+ _tecutil_connector.start_roaming(days)
166
+
167
+
168
+ def stop_roaming(force=False):
169
+ """Check in (release) a roaming license.
170
+
171
+ This will check in and make available to others on the network a license
172
+ that you previously checked out for roaming.
173
+
174
+ See also: `tecplot.session.start_roaming()`
175
+
176
+ Example usage::
177
+
178
+ >>> tecplot.session.stop_roaming()
179
+ Your PyTecplot roaming license has been checked in.
180
+ """
181
+ if _tecutil_connector.connected:
182
+ msg = textwrap.dedent('''\
183
+ Roaming PyTecplot is not available when connected.
184
+ To roam PyTecplot, first disconnect with
185
+ tecplot.session.disconnect(). Roaming with Tecplot 360
186
+ is available under Help -> License Roaming.
187
+ ''')
188
+ raise TecplotLogicError(msg)
189
+ _tecutil_connector.stop_roaming(force)
190
+
191
+
192
+ def license_expiration():
193
+ """Expiration date of the current license.
194
+
195
+ Returns: `datetime.date`
196
+
197
+ Example usage::
198
+
199
+ >>> print(tecplot.session.license_expiration())
200
+ 1955-11-05
201
+ """
202
+ expire = _tecutil_connector.license_expiration
203
+ if isinstance(expire, datetime.date):
204
+ return expire
205
+
206
+
207
+ def connect(host='localhost', port=7600, timeout=10, quiet=False):
208
+ """Connect this PyTecplot to a running instance of Tecplot 360.
209
+
210
+ Parameters:
211
+ host (`str`, optional): The host name or IP address of the machine
212
+ running Tecplot 360 with the :ref:`TecUtil Server <TecUtilServer>`
213
+ addon loaded and listening. (default: localhost)
214
+ port (`int`, optional): The port used by the running Tecplot 360
215
+ instance. (default: 7600)
216
+ timeout (`int`, optional): Number of seconds to wait before giving up.
217
+ (default: 10)
218
+ quiet (`bool`, optional): Suppress status messages sent to the console.
219
+ Exception messages will still be presented on errors. (default:
220
+ `False`)
221
+
222
+ This will connect the running python script to Tecplot 360, sending
223
+ requests over the network. The :ref:`TecUtil Server <TecUtilServer>` addon
224
+ must be loaded and the server must be accepting requests. To turn on the
225
+ server in Tecplot 360, go to the main menu, click on "Scripting ->
226
+ PyTecplot Connections...", and finally check the option to "Accept
227
+ connections." Make sure the same port is used in both Tecplot 360 and the
228
+ python script. For more information, see :ref:`Requirements for Connecting
229
+ to Tecplot 360 GUI <connections>` Example usage::
230
+
231
+ >>> tecplot.session.connect(port=7600)
232
+ Connecting to Tecplot 360 TecUtil Server on:
233
+ tcp://localhost:7600
234
+ Connection established.
235
+
236
+ To activate the :ref:`TecUtil Server <TecUtilServer>` addon in Tecplot 360
237
+ on start-up, first create a macro file, named something like:
238
+ *startTecUtilServer.mcr*, with the following content:
239
+
240
+ .. code-block:: none
241
+
242
+ #!MC 1410
243
+ $!EXTENDEDCOMMAND
244
+ COMMANDPROCESSORID = "TecUtilServer"
245
+ COMMAND = R"(
246
+ AcceptRequests = Yes
247
+ ListenOnAddress = localhost
248
+ ListenOnPort = 7600
249
+ )"
250
+
251
+ Then run Tecplot 360 from a command console with this file as one of the
252
+ arguments::
253
+
254
+ > tec360 startTecUtilServer.mcr
255
+
256
+ .. warning::
257
+
258
+ Adding the macro command above may cause a port binding conflict when
259
+ using multiple instances of Tecplot 360. A single port can only be
260
+ bound to one instance of the :ref:`TecUtil Server <TecUtilServer>`. You
261
+ may still add this to the ``tecplot.add`` file which will be run
262
+ everytime, but it must only be activated when Tecplot 360 is running
263
+ interactively, i.e. not in batch mode. To do this, check the value of
264
+ ``|INBATCHMODE|``:
265
+
266
+ .. code-block:: none
267
+
268
+ $!IF |INBATCHMODE| == 0
269
+ $!EXTENDEDCOMMAND
270
+ COMMANDPROCESSORID = "TecUtilServer"
271
+ COMMAND = R"(
272
+ AcceptRequests = Yes
273
+ ListenOnAddress = localhost
274
+ ListenOnPort = 7600
275
+ )"
276
+ $!ENDIF
277
+
278
+ .. versionadded:: 2017.3
279
+ PyTecplot connections requires Tecplot 360 2017 R3 or later.
280
+ """
281
+ _tecutil_connector.connect(host, port, timeout, quiet)
282
+
283
+
284
+ def connected(timeout=5):
285
+ """Check if PyTecplot is connected to a running instance of Tecplot 360.
286
+
287
+ This method sends a handshake message to the :ref:`TecUtil Server
288
+ <TecUtilServer>` and waits for a successful reply, timing out in the number
289
+ of seconds specified.
290
+
291
+ Parameters:
292
+ timeout (`int`, optional): Number of seconds to wait before giving up.
293
+ (default: 5)
294
+
295
+ .. versionadded:: 2017.3 of Tecplot 360
296
+ PyTecplot connections requires Tecplot 360 2017 R3 or later.
297
+ """
298
+ if _tecutil_connector.connected:
299
+ return _tecutil_connector.client.is_server_listening(timeout)
300
+ else:
301
+ return False
302
+
303
+
304
+ def disconnect(quit=False):
305
+ """Disconnect from a running instance of Tecplot 360.
306
+
307
+ Parameters:
308
+ quit (`bool`, optional): Attempt to quit and close the instance of
309
+ Tecplot 360 before disconnecting.
310
+
311
+ .. versionadded:: 2017.3
312
+ PyTecplot connections requires Tecplot 360 2017 R3 or later.
313
+ """
314
+ if connected():
315
+ if quit:
316
+ _tecutil_connector.client.quit()
317
+ _tecutil_connector.disconnect()
318
+
319
+
320
+ @contextlib.contextmanager
321
+ def suspend():
322
+ """Suspend the Tecplot engine and graphical interface.
323
+
324
+ This context may speed up several types of operations including the
325
+ creation of zones, filling or alterating the underlying data and the setup
326
+ of complex styles. It will put Tecplot 360 into a "suspended" state such
327
+ that the engine (in batch mode) or the graphical interface (in connected
328
+ mode) will not try to keep up with the operations issued from Python. Upon
329
+ exit of this context, the Tecplot 360 will be notified of any data
330
+ alterations that have occured and the interface will be updated
331
+ accordingly.
332
+
333
+ See the `state change` section for more information about how the |Tecplot
334
+ 360| is updated when style or data is changed from a PyTecplot script.
335
+
336
+ Example usage where `data` is some user-provided data -- see the examples
337
+ under ``pytecplot/examples/working_with_datasets`` folder within the Teplot
338
+ 360 installation for more information.::
339
+
340
+ fr = tp.active_frame()
341
+ with tp.session.suspend():
342
+ ds = fr.create_dataset('Data', ['x', 'y', 'z'])
343
+ zn = ds.add_ordered_zone('Zone', (10, 10, 10))
344
+ zn.values('x')[:] = data[0]
345
+ zn.values('y')[:] = data[1]
346
+ zn.values('z')[:] = data[2]
347
+ fr.plot_type = tp.constant.PlotType.Cartesian3D
348
+
349
+ .. versionadded:: 2018.2
350
+ The suspend context, when used in connected mode, requires Tecplot 360
351
+ 2018 R2 or later to realize the full performance benefits though this
352
+ will still provide some performance improvements with older versions of
353
+ Tecplot 360.
354
+ """
355
+ if _tecutil_connector.suspended:
356
+ yield
357
+ else:
358
+ _tecutil_connector.suspended = True
359
+ _tecutil_connector._state_changes = {}
360
+ _tecutil_connector._delete_caches = []
361
+ try:
362
+ if _tecutil_connector.connected:
363
+ with _tecutil_connector.client.suspend_interface():
364
+ yield
365
+ _emit_state_changes(_tecutil_connector._state_changes)
366
+ else:
367
+ yield
368
+ _emit_state_changes(_tecutil_connector._state_changes)
369
+ finally:
370
+ for delete_cache in _tecutil_connector._delete_caches:
371
+ delete_cache()
372
+ del _tecutil_connector._state_changes
373
+ _tecutil_connector.suspended = False
374
+
375
+
376
+ def suspend_enter():
377
+ """Free-function equivalent to entering the `suspend` context.
378
+
379
+ This is an example of calling *a previously defined function* ``do_work()``
380
+ within a suspend context, using ``try/finally`` to ensure the context is
381
+ properly cleared:
382
+
383
+ >>> try:
384
+ >>> tp.session.suspend_enter()
385
+ >>> do_work()
386
+ >>> finally:
387
+ >>> tp.session.suspend_exit()
388
+ """
389
+ if not hasattr(_tecutil_connector, 'suspend_context'):
390
+ _tecutil_connector.suspend_context = suspend()
391
+ _tecutil_connector.suspend_context.__enter__()
392
+
393
+
394
+ def suspend_exit():
395
+ """Free-function equivalent to exiting the `suspend` context.
396
+
397
+ This must only be used following a call to
398
+ `tecplot.session.suspend_enter()` and cannot be used within a
399
+ `tecplot.session.suspend()` context block.
400
+ """
401
+ if not hasattr(_tecutil_connector, 'suspend_context'):
402
+ raise TecplotLogicError('not in suspend context')
403
+ _tecutil_connector.suspend_context.__exit__(None, None, None)
404
+ delattr(_tecutil_connector, 'suspend_context')
405
+
406
+
407
+ def clear_suspend():
408
+ """Break out of suspended mode when connected to Tecplot 360.
409
+
410
+ Forcibly clears the suspend state of the Tecplot 360 interface. This will
411
+ cause the :ref:`TecUtil Server <TecUtilServer>` to break out of a suspended
412
+ state which may have been the result of a script not properly exiting from
413
+ a `suspend()` context, possibly due to a segmentation fault. Example
414
+ usage::
415
+
416
+ tecplot.session.connect()
417
+ tecplot.session.clear_suspend()
418
+ """
419
+ assert not _tecutil_connector.suspended, 'Can not clear in suspend context'
420
+ assert _tecutil_connector.connected, 'Not connected to TecUtil Server'
421
+ _tecutil_connector.client.clear_suspend_interface()
422
+
423
+
424
+ # Ensure the Tecplot engine is cleaned up on exit if started.
425
+ atexit.register(stop)
@@ -0,0 +1,225 @@
1
+ import collections
2
+ import ctypes
3
+
4
+ from ..tecutil import _tecutil, _tecutil_connector
5
+ from .. import tecutil
6
+ from ..constant import StateChange
7
+ from ..exception import TecplotLogicError
8
+
9
+
10
+ @tecutil.lock()
11
+ def _state_changed(what, uniqueid=None, dataset=None, zones=None,
12
+ variables=None, index=None):
13
+ sv = tecutil.sv
14
+ allocd = []
15
+ try:
16
+ with tecutil.ArgList() as arglist:
17
+ arglist[sv.STATECHANGE] = what
18
+ if uniqueid is not None:
19
+ arglist[sv.UNIQUEID] = ctypes.c_size_t(uniqueid)
20
+ if dataset is not None:
21
+ arglist[sv.DATASETUNIQUEID] = ctypes.c_size_t(dataset)
22
+ if zones:
23
+ zonelist = tecutil.IndexSet(*zones)
24
+ allocd.append(zonelist)
25
+ arglist[sv.ZONELIST] = zonelist
26
+ if variables:
27
+ varlist = tecutil.IndexSet(*variables)
28
+ allocd.append(varlist)
29
+ arglist[sv.VARLIST] = varlist
30
+ if index is not None:
31
+ arglist[sv.INDEX] = index + 1
32
+ _tecutil.StateChangedX(arglist)
33
+ finally:
34
+ for a in allocd:
35
+ a.dealloc()
36
+
37
+
38
+ def zone_added(zone):
39
+
40
+ sc_type = StateChange.ZonesAdded
41
+ dataset = zone.dataset.uid
42
+ zone_index = zone.index
43
+ zone = set([zone_index])
44
+
45
+ if _tecutil_connector.suspended:
46
+
47
+ # add zone added to state change data
48
+ sc = _tecutil_connector._state_changes
49
+ if sc_type not in sc:
50
+ sc[sc_type] = {dataset: zone}
51
+ elif dataset not in sc[sc_type]:
52
+ sc[sc_type][dataset] = zone
53
+ else:
54
+ sc[sc_type][dataset] |= zone
55
+
56
+ # remove any vars altered state change for this zone
57
+ sc_type = StateChange.VarsAltered
58
+ try:
59
+ del sc[sc_type][dataset][zone_index]
60
+ if len(sc[sc_type][dataset]) == 0:
61
+ del sc[sc_type][dataset]
62
+ if len(sc[sc_type]) == 1:
63
+ del sc[sc_type]
64
+ except KeyError:
65
+ pass
66
+
67
+ # remove any connectivity state change for this zone
68
+ sc_type = StateChange.NodeMapsAltered
69
+ try:
70
+ sc[sc_type][dataset] -= zone
71
+ if len(sc[sc_type][dataset]) == 0:
72
+ del sc[sc_type][dataset]
73
+ if len(sc[sc_type]) == 1:
74
+ del sc[sc_type]
75
+ except KeyError:
76
+ pass
77
+ else:
78
+ _state_changed(sc_type, dataset=dataset, zones=zone)
79
+
80
+
81
+ def data_altered(zone, variable, index=None):
82
+ if __debug__:
83
+ if zone.dataset != variable.dataset:
84
+ msg = 'Zone and variable are not part of the same dataset.'
85
+ raise TecplotLogicError(msg)
86
+
87
+ sc_type = StateChange.VarsAltered
88
+ dataset = zone.dataset.uid
89
+ zone = zone.index
90
+ variable = variable.index
91
+
92
+ if _tecutil_connector.suspended:
93
+ index = set([index])
94
+ sc = _tecutil_connector._state_changes
95
+ try:
96
+ # only add state change if a zones added is not already set
97
+ if zone not in sc[StateChange.ZonesAdded][dataset]:
98
+ raise KeyError
99
+ except KeyError:
100
+ if sc_type not in sc:
101
+ sc[sc_type] = {dataset: {zone: {variable: index}}}
102
+ elif dataset not in sc[sc_type]:
103
+ sc[sc_type][dataset] = {zone: {variable: index}}
104
+ elif zone not in sc[sc_type][dataset]:
105
+ sc[sc_type][dataset][zone] = {variable: index}
106
+ elif variable not in sc[sc_type][dataset][zone]:
107
+ sc[sc_type][dataset][zone][variable] = index
108
+ elif sc[sc_type][dataset][zone][variable] != set([None]):
109
+ if index == set([None]):
110
+ sc[sc_type][dataset][zone][variable] = set([None])
111
+ else:
112
+ sc[sc_type][dataset][zone][variable] |= index
113
+ else:
114
+ _state_changed(sc_type, dataset=dataset, zones=[zone],
115
+ variables=[variable], index=index)
116
+
117
+
118
+ def connectivity_altered(zone):
119
+
120
+ sc_type = StateChange.NodeMapsAltered
121
+ dataset = zone.dataset.uid
122
+ zone = set([zone.index])
123
+
124
+ if _tecutil_connector.suspended:
125
+ sc = _tecutil_connector._state_changes
126
+ try:
127
+ # only add state change if a zones added is not already set
128
+ if zone.isdisjoint(sc[StateChange.ZonesAdded][dataset]):
129
+ raise KeyError
130
+ except KeyError:
131
+ if sc_type not in sc:
132
+ sc[sc_type] = {dataset: zone}
133
+ elif dataset not in sc[sc_type]:
134
+ sc[sc_type][dataset] = zone
135
+ else:
136
+ sc[sc_type][dataset] |= zone
137
+ else:
138
+ _state_changed(sc_type, dataset=dataset, zones=zone)
139
+
140
+
141
+ def _emit_state_changes(state_changes):
142
+ for sc_type, info in state_changes.items():
143
+ if sc_type in (StateChange.ZonesAdded, StateChange.NodeMapsAltered):
144
+ for dataset, zones in info.items():
145
+ _state_changed(sc_type, dataset=dataset, zones=zones)
146
+ elif sc_type == StateChange.VarsAltered:
147
+ for dataset in info:
148
+ for zone in info[dataset]:
149
+ for variable in info[dataset][zone]:
150
+ for index in info[dataset][zone][variable]:
151
+ _state_changed(sc_type, dataset=dataset,
152
+ zones=[zone], variables=[variable],
153
+ index=index)
154
+
155
+ '''
156
+ class StateChange(Enum):
157
+ VarsAltered = 0
158
+ VarsAdded = 1
159
+ ZonesDeleted = 2
160
+ ZonesAdded = 3
161
+ NodeMapsAltered = 4
162
+ FrameDeleted = 5
163
+ #NewTopFrame = 6 /* deprecated: use NewActiveFrame and/or FrameOrderChange */
164
+ Style = 7
165
+ DataSetReset = 8
166
+ NewLayout = 9
167
+ #CompleteReset = 10 /* deprecated: no longer broadcast */
168
+ LineMapAssignment = 11
169
+ ContourLevels = 12
170
+ ModalDialogLaunch = 13
171
+ ModalDialogDismiss = 14
172
+ QuitTecplot = 15
173
+ ZoneName = 16
174
+ VarName = 17
175
+ LineMapName = 18
176
+ LineMapAddDeleteOrReorder = 19
177
+ View = 20
178
+ ColorMap = 21
179
+ ContourVar = 22
180
+ Streamtrace = 23
181
+ NewAxisVariables = 24
182
+ MouseModeUpdate = 25
183
+ PickListCleared = 26
184
+ PickListGroupSelect = 27
185
+ PickListSingleSelect = 28
186
+ PickListStyle = 29
187
+ JournalReset = 30
188
+ UnsuspendInterface = 31
189
+ SuspendInterface = 32
190
+ DataSetLockOn = 33
191
+ DataSetLockOff = 34
192
+ Text = 35
193
+ Geom = 36
194
+ DataSetTitle = 37
195
+ DrawingInterrupted = 38
196
+ PrintPreviewLaunch = 39
197
+ PrintPreviewDismiss = 40
198
+ AuxDataAdded = 41
199
+ AuxDataDeleted = 42
200
+ AuxDataAltered = 43
201
+ VarsDeleted = 44
202
+ TecplotIsInitialized = 45
203
+ ImageExported = 46
204
+ VariableLockOn = 47
205
+ VariableLockOff = 48
206
+ PageDeleted = 49
207
+ NewTopPage = 50
208
+ NewActiveFrame = 51
209
+ FrameOrderChanged = 52
210
+ NewUndoState = 53
211
+ MacroFunctionListChanged = 54
212
+ AnimationStart = 55
213
+ AnimationEnd = 56
214
+ MacroRecordingStarted = 57
215
+ MacroRecordingEnded = 58
216
+ MacroRecordingCanceled = 59
217
+ ZoneSolutionTimeAltered = 60
218
+ LayoutAssociation = 61
219
+ CopyView = 62
220
+ ColorMapDeleted = 63
221
+ OpenLayout = 64
222
+ MacroLoaded = 65
223
+ PerformingUndoBegin = 66
224
+ PerformingUndoEnd = 67
225
+ '''