simplex-solver 3.2.2__cp39-abi3-win_amd64.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 (84) hide show
  1. simplex_solver-3.2.2.dist-info/DELVEWHEEL +2 -0
  2. simplex_solver-3.2.2.dist-info/METADATA +94 -0
  3. simplex_solver-3.2.2.dist-info/RECORD +84 -0
  4. simplex_solver-3.2.2.dist-info/WHEEL +5 -0
  5. simplex_solver.libs/.load-order-simplex_solver-3.2.2 +1 -0
  6. simplex_solver.libs/msvcp140-a4c2229bdc2a2a630acdc095b4d86008.dll +0 -0
  7. simplexui/__init__.py +86 -0
  8. simplexui/_version.py +1 -0
  9. simplexui/channelBox.py +867 -0
  10. simplexui/comboCheckDialog.py +396 -0
  11. simplexui/commands/__init__.py +16 -0
  12. simplexui/commands/alembicCommon.py +1148 -0
  13. simplexui/commands/alembic_walker.py +299 -0
  14. simplexui/commands/applyCorrectives.py +452 -0
  15. simplexui/commands/correctiveInterface.py +259 -0
  16. simplexui/commands/expandedExport.py +434 -0
  17. simplexui/commands/hdf5Convert.py +62 -0
  18. simplexui/commands/mayaCorrectiveInterface.py +159 -0
  19. simplexui/commands/mayatonumpy.py +416 -0
  20. simplexui/commands/mesh.py +1085 -0
  21. simplexui/commands/poseblendlib.py +168 -0
  22. simplexui/commands/reorderSimplexPoints.py +102 -0
  23. simplexui/commands/replaceDefinitionJson.py +74 -0
  24. simplexui/commands/rigidAlign.py +97 -0
  25. simplexui/commands/unsubdivide.py +1222 -0
  26. simplexui/commands/uvTransfer.py +976 -0
  27. simplexui/dragFilter.py +334 -0
  28. simplexui/falloffDialog.py +504 -0
  29. simplexui/img/ChefHead.png +0 -0
  30. simplexui/img/frozen.png +0 -0
  31. simplexui/interface/__init__.py +30 -0
  32. simplexui/interface/dummyInterface.py +1313 -0
  33. simplexui/interface/mayaInterface.py +2294 -0
  34. simplexui/interfaceModel.py +655 -0
  35. simplexui/interfaceModelTrees.py +456 -0
  36. simplexui/items/__init__.py +50 -0
  37. simplexui/items/accessor.py +145 -0
  38. simplexui/items/combo.py +645 -0
  39. simplexui/items/dragItem.py +44 -0
  40. simplexui/items/falloff.py +748 -0
  41. simplexui/items/group.py +267 -0
  42. simplexui/items/progression.py +613 -0
  43. simplexui/items/shape.py +384 -0
  44. simplexui/items/simplex.py +1734 -0
  45. simplexui/items/slider.py +632 -0
  46. simplexui/items/stack.py +147 -0
  47. simplexui/items/traversal.py +780 -0
  48. simplexui/items/treeItem.py +441 -0
  49. simplexui/main.pyw +22 -0
  50. simplexui/menu/__init__.py +73 -0
  51. simplexui/menu/dummyPlugins/__init__.py +16 -0
  52. simplexui/menu/genericPlugins/__init__.py +16 -0
  53. simplexui/menu/genericPlugins/_builtins.py +270 -0
  54. simplexui/menu/genericPlugins/checkPossibleCombos.py +48 -0
  55. simplexui/menu/genericPlugins/exportSplit.py +67 -0
  56. simplexui/menu/genericPlugins/showFalloffs.py +26 -0
  57. simplexui/menu/genericPlugins/showTraversals.py +26 -0
  58. simplexui/menu/genericPlugins/simplexUvTransfer.py +106 -0
  59. simplexui/menu/genericPlugins/unsubdivide.py +72 -0
  60. simplexui/menu/mayaPlugins/__init__.py +16 -0
  61. simplexui/menu/mayaPlugins/exportOther.py +53 -0
  62. simplexui/menu/mayaPlugins/extractProgressives.py +68 -0
  63. simplexui/menu/mayaPlugins/freezeCombo.py +247 -0
  64. simplexui/menu/mayaPlugins/generateShapeIncrementals.py +99 -0
  65. simplexui/menu/mayaPlugins/importObjs.py +199 -0
  66. simplexui/menu/mayaPlugins/linearizeTraversal.py +60 -0
  67. simplexui/menu/mayaPlugins/makeShelfBtn.py +67 -0
  68. simplexui/menu/mayaPlugins/relaxToSelection.py +76 -0
  69. simplexui/menu/mayaPlugins/reloadDefinition.py +44 -0
  70. simplexui/menu/mayaPlugins/snapToNeutral.py +71 -0
  71. simplexui/menu/mayaPlugins/softSelectToCluster.py +201 -0
  72. simplexui/menu/mayaPlugins/tweakMix.py +136 -0
  73. simplexui/menu/mayaPlugins/updateRestShape.py +113 -0
  74. simplexui/pysimplex.lib +0 -0
  75. simplexui/pysimplex.pyd +0 -0
  76. simplexui/simplexDialog.py +1547 -0
  77. simplexui/travCheckDialog.py +419 -0
  78. simplexui/traversalDialog.py +299 -0
  79. simplexui/ui/comboCheckDialog.ui +475 -0
  80. simplexui/ui/falloffDialog.ui +243 -0
  81. simplexui/ui/simplexDialog.ui +1458 -0
  82. simplexui/ui/travCheckDialog.ui +488 -0
  83. simplexui/ui/traversalDialog.ui +532 -0
  84. simplexui/utils.py +307 -0
@@ -0,0 +1,456 @@
1
+ # Copyright 2016, Blur Studio
2
+ #
3
+ # This file is part of Simplex.
4
+ #
5
+ # Simplex is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # Simplex is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with Simplex. If not, see <http://www.gnu.org/licenses/>.
17
+ from __future__ import annotations
18
+
19
+ from typing import cast
20
+
21
+ from Qt.QtCore import (
22
+ QItemSelection,
23
+ QItemSelectionModel,
24
+ QModelIndex,
25
+ Qt,
26
+ )
27
+ from Qt.QtGui import QValidator
28
+ from Qt.QtWidgets import QApplication, QLineEdit, QMenu, QStyledItemDelegate, QTreeView, QWidget
29
+
30
+ from .dragFilter import DragFilter
31
+ from .interfaceModel import SimplexFilterModel
32
+ from .items import Group
33
+ from .items.dragItem import Draggable
34
+ from .items.treeItem import CustomRoles
35
+ from .utils import execmenu
36
+
37
+
38
+ class NameValidator(QValidator):
39
+ def __init__(self, parent: QLineEdit | None = None) -> None:
40
+ super().__init__(parent)
41
+
42
+ def validate(self, input_str: str, pos: int) -> tuple[QValidator.State, str, int]:
43
+ if not input_str:
44
+ return QValidator.State.Intermediate, input_str, pos
45
+ if input_str.isidentifier():
46
+ return QValidator.State.Acceptable, input_str, pos
47
+ return QValidator.State.Invalid, input_str, pos
48
+
49
+
50
+ class SimplexNameDelegate(QStyledItemDelegate):
51
+ """An QStyledItemDelegate subclass that implements a Regex validator"""
52
+
53
+ def createEditor(self, parent, option, index) -> QLineEdit:
54
+ editor = QLineEdit(parent)
55
+ validator = NameValidator(editor)
56
+ editor.setValidator(validator)
57
+ return editor
58
+
59
+
60
+ class SimplexTree(QTreeView):
61
+ """Abstract base tree displaying Simplex objects"""
62
+
63
+ def __init__(self, parent: QWidget) -> None:
64
+ super().__init__(parent)
65
+
66
+ self.expandModifier = Qt.KeyboardModifier.ControlModifier
67
+ self.depthModifier = Qt.KeyboardModifier.ShiftModifier
68
+ self._expansions: set[str] = set()
69
+
70
+ self._menu = None
71
+ self._plugins = []
72
+
73
+ self.expanded.connect(self.expandTree)
74
+ self.collapsed.connect(self.collapseTree)
75
+ self.connectMenus()
76
+
77
+ self.dragFilter = DragFilter(self.viewport())
78
+ self.viewport().installEventFilter(self.dragFilter)
79
+
80
+ self.dragFilter.dragTick.connect(self.dragTick)
81
+
82
+ self.delegate = SimplexNameDelegate(self)
83
+ self.setItemDelegateForColumn(0, self.delegate)
84
+
85
+ self.setColumnWidth(1, 50)
86
+ self.setColumnWidth(2, 20)
87
+
88
+ def setModel(self, model: SimplexFilterModel) -> None:
89
+ super().setModel(model)
90
+
91
+ def model(self) -> SimplexFilterModel:
92
+ return cast(SimplexFilterModel, super().model())
93
+
94
+ def setPlugins(self, plugins) -> None:
95
+ """Set the right-click menu plugins for the tree
96
+
97
+ Parameters
98
+ ----------
99
+ plugins : list
100
+ The list of plugins for the tree
101
+ """
102
+ self._plugins = plugins
103
+
104
+ def unifySelection(self) -> None:
105
+ """Handle selection across multiple Trees.
106
+ The other tree's selectionChanged signal will be connected to this
107
+ And it will clear the selection on this tree if no modifiers are being held
108
+ """
109
+ mods = QApplication.keyboardModifiers()
110
+ if not mods & (
111
+ Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.ShiftModifier
112
+ ):
113
+ selModel = self.selectionModel()
114
+ selModel.blockSignals(True)
115
+ try:
116
+ selModel.clearSelection()
117
+ finally:
118
+ selModel.blockSignals(False)
119
+ self.viewport().update()
120
+
121
+ def hideRedundant(self, check) -> None:
122
+ """Update the filter model to show/hide single shapes
123
+
124
+ Parameters
125
+ ----------
126
+ check : bool
127
+ Whether to hid redundant
128
+ """
129
+ model = self.model()
130
+ model.filterShapes = check
131
+ model.invalidateFilter()
132
+
133
+ def stringFilter(self, filterString) -> None:
134
+ """Update the filter model with a filter string
135
+
136
+ Parameters
137
+ ----------
138
+ filterString : str
139
+ The string to filter on
140
+ """
141
+ model = self.model()
142
+ model.filterString = str(filterString)
143
+ model.invalidateFilter()
144
+
145
+ def isolate(self, sliderNames) -> None:
146
+ """Update the filter model with a whitelist of names
147
+
148
+ Parameters
149
+ ----------
150
+ sliderNames : [str, ...]
151
+ The names items to show
152
+ """
153
+ model = self.model()
154
+ model.isolateList = sliderNames
155
+ model.invalidateFilter()
156
+
157
+ def isolateSelected(self) -> None:
158
+ """Isolate the selected items"""
159
+ items = self.getSelectedItems()
160
+ isoList = [i.name for i in items]
161
+ self.isolate(isoList)
162
+
163
+ def exitIsolate(self) -> None:
164
+ """Remove all items from isolation"""
165
+ self.isolate([])
166
+
167
+ # Tree expansion/collapse code
168
+ def expandTree(self, index) -> None:
169
+ """Expand all items under index
170
+
171
+ Parameters
172
+ ----------
173
+ index : QModelIndex
174
+ The index to recursively expand
175
+ """
176
+ self.toggleTree(index, True)
177
+
178
+ def collapseTree(self, index) -> None:
179
+ """Collapse all items under index
180
+
181
+ Parameters
182
+ ----------
183
+ index : QModelIndex
184
+ The index to recursively collapse
185
+ """
186
+ self.toggleTree(index, False)
187
+
188
+ def resizeColumns(self) -> None:
189
+ '''Resize all columns to their contents "smartly"'''
190
+ model = self.model()
191
+ for i in range(model.columnCount() - 1):
192
+ oldcw = self.columnWidth(i)
193
+ self.resizeColumnToContents(i)
194
+ newcw = self.columnWidth(i) + 10
195
+ self.setColumnWidth(i, max(oldcw, newcw, 30))
196
+ self.setColumnWidth(model.columnCount() - 1, 5)
197
+
198
+ def toggleTree(self, index, expand: bool) -> None:
199
+ """Recursively expand or collapse an entire sub-tree of an
200
+ index. If certain modifiers are held, then only a partial
201
+ sub-tree will be expanded
202
+
203
+ Parameters
204
+ ----------
205
+ index : QModelIndex
206
+ The index to change expansion
207
+ expand : bool
208
+ Whether to expand or collapse the item
209
+ """
210
+ # Separate function to deal with filtering capability
211
+ if not index.isValid():
212
+ return
213
+
214
+ model = self.model()
215
+ mods = QApplication.keyboardModifiers()
216
+ thing = model.itemFromIndex(index)
217
+
218
+ if mods & (self.expandModifier | self.depthModifier):
219
+ queue = [index]
220
+ self.blockSignals(True)
221
+ try:
222
+ while queue:
223
+ idx = queue.pop()
224
+ thing = model.itemFromIndex(idx)
225
+ self.setExpanded(idx, expand)
226
+ if mods & self.depthModifier:
227
+ if isinstance(thing, Group):
228
+ continue
229
+ for i in range(model.rowCount(idx)):
230
+ child = model.index(i, 0, idx)
231
+ if child and child.isValid():
232
+ queue.append(child)
233
+ finally:
234
+ self.blockSignals(False)
235
+
236
+ if expand:
237
+ self.resizeColumns()
238
+
239
+ def expandToItem(self, item) -> None:
240
+ """Make sure that all parents leading to `item` are expanded
241
+
242
+ Parameters
243
+ ----------
244
+ item : object
245
+ The item to expand to
246
+ """
247
+ model = self.model()
248
+ index = model.indexFromItem(item)
249
+ self.expandToIndex(index)
250
+
251
+ def expandToIndex(self, index: QModelIndex) -> None:
252
+ """Make sure that all parents leading to `index` are expanded
253
+
254
+ Parameters
255
+ ----------
256
+ index : QModelIndex
257
+ The index to expand to
258
+ """
259
+ while index and index.isValid():
260
+ self.setExpanded(index, True)
261
+ index = index.parent()
262
+ self.resizeColumns()
263
+
264
+ def scrollToItem(self, item) -> None:
265
+ """Ensure that the item is scrolled to in the tree
266
+
267
+ Parameters
268
+ ----------
269
+ item : object
270
+ The Item to expand to
271
+ """
272
+ model = self.model()
273
+ index = model.indexFromItem(item)
274
+ self.scrollToIndex(index)
275
+
276
+ def scrollToIndex(self, index: QModelIndex) -> None:
277
+ """Ensure that the index is scrolled to in the tree
278
+
279
+ Parameters
280
+ ----------
281
+ index : QModelIndex
282
+ The Index to expand to
283
+
284
+ """
285
+ self.expandToIndex(index)
286
+ self.scrollTo(index)
287
+
288
+ def storeExpansion(self) -> None:
289
+ """Store the expansion state of the tree for the undo stack"""
290
+ expanded_uids = set()
291
+ model = self.model()
292
+ for index in model.iterindices(pred=lambda x: self.isExpanded(x)):
293
+ uid = model.data(index, CustomRoles.UID_ROLE)
294
+ if uid:
295
+ expanded_uids.add(uid)
296
+ self._expansions = expanded_uids
297
+
298
+ def setItemExpansion(self) -> None:
299
+ """Load the stored expansions onto the tree"""
300
+ model = self.model()
301
+ for index in model.iterindices(
302
+ pred=lambda x: model.data(x, CustomRoles.UID_ROLE) in self._expansions
303
+ ):
304
+ self.setExpanded(index, True)
305
+
306
+ def dragTick(self, ticks, mul) -> None:
307
+ """Deal with the ticks coming from the drag handler
308
+
309
+ Parameters
310
+ ----------
311
+ ticks : int
312
+ The number and direction of update ticks coming from the drag handler
313
+ mul : float
314
+ The multiplier based on user hotkeys
315
+ """
316
+ selModel = self.selectionModel()
317
+ if not selModel:
318
+ return
319
+ items = self.getSelectedItems()
320
+ for item in items:
321
+ if isinstance(item, Draggable):
322
+ item.valueTick(ticks, mul)
323
+ self.viewport().update()
324
+
325
+ # Menus and Actions
326
+ def connectMenus(self) -> None:
327
+ """Setup the QT signal/slot connections to the context menus"""
328
+ self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
329
+ self.customContextMenuRequested.connect(self.openMenu)
330
+
331
+ def openMenu(self, pos) -> None:
332
+ """Handle getting the data to show the context menu
333
+
334
+ Parameters
335
+ ----------
336
+ pos : QPoint
337
+ The position of the click
338
+ """
339
+ clickIdx = self.indexAt(pos)
340
+ selIdxs = self.getSelectedIndexes()
341
+ if self.window().simplex is None:
342
+ return
343
+ self.showContextMenu(clickIdx, selIdxs, self.viewport().mapToGlobal(pos))
344
+
345
+ def showContextMenu(self, clickIdx: QModelIndex, indexes, pos) -> None:
346
+ """Handle showing the context menu items from the plugins
347
+
348
+ Parameters
349
+ ----------
350
+ clickIdx : QModelIndex
351
+ The model index that was clicked
352
+ indexes : [QModelIndex, ...]
353
+ The indexes that were selected
354
+ pos : QPoint
355
+ The position of the click
356
+ """
357
+ menu = QMenu()
358
+ for plug in self._plugins:
359
+ plug.registerContext(self, clickIdx, indexes, menu)
360
+
361
+ execmenu(menu, pos)
362
+
363
+ # Selection
364
+ def getSelectedItems(self, typ=None):
365
+ """Get the selected tree items
366
+
367
+ Parameters
368
+ ----------
369
+ typ : Type
370
+ Only return selected items of this type. Optional
371
+
372
+ Returns
373
+ -------
374
+ [object, ...]
375
+ A list of selected tree items
376
+ """
377
+ selModel = self.selectionModel()
378
+ if not selModel:
379
+ return []
380
+ selIdxs = selModel.selectedIndexes()
381
+ selIdxs = [i for i in selIdxs if i.column() == 0]
382
+ model = self.model()
383
+ items = [model.itemFromIndex(i) for i in selIdxs]
384
+ if typ is not None:
385
+ items = [i for i in items if isinstance(i, typ)]
386
+ return items
387
+
388
+ def getSelectedIndexes(self, filtered: bool = False):
389
+ """Get selected indexes for either the filtered or unfiltered models
390
+
391
+ Parameters
392
+ ----------
393
+ filtered : bool
394
+ Whether the model is filtered or not. Defaults to False
395
+
396
+ Returns
397
+ -------
398
+ [QModelIndex, ...]
399
+ A list of selected indexes
400
+ """
401
+ selModel = self.selectionModel()
402
+ if not selModel:
403
+ return []
404
+ selIdxs = selModel.selectedIndexes()
405
+ if filtered:
406
+ return selIdxs
407
+
408
+ model = self.model()
409
+ indexes = [model.mapToSource(i) for i in selIdxs]
410
+ return indexes
411
+
412
+ def setItemSelection(self, items) -> None:
413
+ """Set the selection based on a list of items
414
+
415
+ Parameters
416
+ ----------
417
+ items : [object, ...]
418
+ List of items to select
419
+ """
420
+ model = self.model()
421
+ idxs = [model.indexFromItem(i) for i in items]
422
+ idxs = [i for i in idxs if i and i.isValid()]
423
+
424
+ toSel = QItemSelection()
425
+ for idx in idxs:
426
+ toSel.merge(
427
+ QItemSelection(idx, idx), QItemSelectionModel.SelectionFlag.Select
428
+ )
429
+
430
+ for idx in idxs:
431
+ par = idx.parent()
432
+ if par.isValid():
433
+ self.scrollToIndex(par)
434
+
435
+ selModel = self.selectionModel()
436
+ selModel.select(toSel, QItemSelectionModel.SelectionFlag.ClearAndSelect)
437
+
438
+
439
+ # Currently, there's no difference between these
440
+ # Later on, though, they may be different
441
+ class SliderTree(SimplexTree):
442
+ """A SimplexTree sub-class for sliders"""
443
+
444
+ pass
445
+
446
+
447
+ class ComboTree(SimplexTree):
448
+ """A SimplexTree sub-class for combos"""
449
+
450
+ pass
451
+
452
+
453
+ class TraversalTree(SimplexTree):
454
+ """A SimplexTree sub-class for traversals"""
455
+
456
+ pass
@@ -0,0 +1,50 @@
1
+ # Copyright 2016, Blur Studio
2
+ #
3
+ # This file is part of Simplex.
4
+ #
5
+ # Simplex is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # Simplex is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with Simplex. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ from __future__ import annotations
19
+
20
+ from .combo import Combo, ComboPair
21
+ from .falloff import Falloff, MapFalloff, PlanarFalloff
22
+ from .group import Group
23
+ from .progression import ProgPair, Progression
24
+ from .shape import Shape
25
+ from .simplex import Simplex
26
+ from .slider import Slider
27
+ from .stack import Stack, stackable
28
+ from .traversal import Traversal, TravPair, TravPoint, TravSide
29
+ from .treeItem import TreeItem
30
+
31
+ __all__ = [
32
+ "Combo",
33
+ "ComboPair",
34
+ "Falloff",
35
+ "MapFalloff",
36
+ "PlanarFalloff",
37
+ "Group",
38
+ "ProgPair",
39
+ "Progression",
40
+ "Shape",
41
+ "Simplex",
42
+ "Slider",
43
+ "Stack",
44
+ "stackable",
45
+ "Traversal",
46
+ "TravPoint",
47
+ "TravPair",
48
+ "TravSide",
49
+ "TreeItem",
50
+ ]
@@ -0,0 +1,145 @@
1
+ # Copyright 2016, Blur Studio
2
+ #
3
+ # This file is part of Simplex.
4
+ #
5
+ # Simplex is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # Simplex is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with Simplex. If not, see <http://www.gnu.org/licenses/>.
17
+ from __future__ import annotations
18
+
19
+ import copy
20
+ from typing import TYPE_CHECKING
21
+
22
+ from .treeItem import TreeItem
23
+
24
+ if TYPE_CHECKING:
25
+ from .simplex import Simplex
26
+ from .stack import Stack
27
+
28
+
29
+ class SimplexAccessor:
30
+ """The base object for all Simplex System object types
31
+ This class provides access to the simplex system
32
+ name getters/setters/unifiers, proper deepcopying, and abstract tree lookup
33
+ """
34
+
35
+ def __init__(self, simplex: Simplex) -> None:
36
+ self.simplex: Simplex = simplex
37
+ self._name: str = ""
38
+ self._splitApplied = set()
39
+
40
+ @property
41
+ def name(self) -> str:
42
+ return self._name
43
+
44
+ @property
45
+ def DCC(self):
46
+ return self.simplex.DCC
47
+
48
+ @property
49
+ def stack(self) -> Stack:
50
+ return self.simplex.stack
51
+
52
+ def __deepcopy__(self, memo):
53
+ cls = self.__class__
54
+ result = cls.__new__(cls)
55
+ memo[id(self)] = result
56
+ for k, v in self.__dict__.items():
57
+ if k == "_thing" and self.DCC.program != "dummy":
58
+ # DO NOT make a copy of the DCC thing (unless its a dummy dcc)
59
+ # as it may or may not be a persistent object
60
+ # setattr(result, k, self._thing)
61
+ setattr(result, k, None)
62
+ elif k == "expanded":
63
+ # Skip the expanded dict because it deals with the Qt models
64
+ setattr(result, k, {})
65
+ else:
66
+ setattr(result, k, copy.deepcopy(v, memo))
67
+ return result
68
+
69
+ def _buildLinkedRename(
70
+ self,
71
+ newName: str,
72
+ maxDepth: int,
73
+ currentLinks: dict[type, dict[str, tuple[SimplexAccessor, int]]],
74
+ ):
75
+ """Build the proposed set of renames specifically for this object
76
+ This allows sub-classes to override the linked name behavior
77
+ """
78
+ return currentLinks
79
+
80
+ def buildLinkedRename(
81
+ self,
82
+ newName: str,
83
+ maxDepth: int = 5,
84
+ currentLinks: dict[type, dict[str, tuple[SimplexAccessor, int]]] | None = None,
85
+ ) -> dict[type, dict[str, tuple[SimplexAccessor, int]]]:
86
+ """For the Shape, Slider, Combo, and Traversal items, build a linked rename
87
+ dictionary like {itemType: {newName: (item, maxDepth)}} recursively up to a
88
+ maximum given depth
89
+
90
+ The dictionary is structured like that to easily check for name clashes
91
+
92
+ Parameters
93
+ ----------
94
+ newName : str
95
+ The new suggested name for this object
96
+ maxDepth : int
97
+ The maximum depth of recursion when resolving names (Default value = 5)
98
+ currentLinks : dict
99
+ The current set of proposed renames. (Default value = None)
100
+
101
+ Returns
102
+ -------
103
+ dict :
104
+ A new set of propsed renames
105
+ """
106
+ # Build the output dict if not done already
107
+ if currentLinks is None:
108
+ currentLinks = {}
109
+
110
+ # return at depth
111
+ if maxDepth <= 0:
112
+ return currentLinks
113
+
114
+ # If this doesn't need renamed, then we can prune this branch
115
+ if self.name == newName:
116
+ return currentLinks
117
+
118
+ # Check for conflicts, or other short circuits
119
+ typeLinks = currentLinks.setdefault(type(self), {})
120
+ if newName in typeLinks:
121
+ tlPair = typeLinks[newName]
122
+ if tlPair[0] is not self:
123
+ # Error out if a name conflict is found.
124
+ msg = "Linked rename produced a conflict: Trying to rename {0} {1} and {2} to {3}"
125
+ msg = msg.format(
126
+ type(self), typeLinks[newName][0].name, self.name, newName
127
+ )
128
+ raise ValueError(msg)
129
+ elif tlPair[1] >= maxDepth:
130
+ # If we've been here before with more available depth
131
+ # then we can just return because we've done this before
132
+ return currentLinks
133
+
134
+ # Finally add myself to the rename
135
+ typeLinks[newName] = (self, maxDepth)
136
+
137
+ # And now handle the type-specific stuff
138
+ return self._buildLinkedRename(newName, maxDepth, currentLinks)
139
+
140
+
141
+ class SimplexTreeAccessor(SimplexAccessor, TreeItem):
142
+ def __init__(self, simplex: Simplex) -> None:
143
+ # Explicitly
144
+ SimplexAccessor.__init__(self, simplex)
145
+ TreeItem.__init__(self, simplex)