simplex-solver 3.1.0__39-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 (79) hide show
  1. simplex_solver-3.1.0.dist-info/METADATA +90 -0
  2. simplex_solver-3.1.0.dist-info/RECORD +79 -0
  3. simplex_solver-3.1.0.dist-info/WHEEL +5 -0
  4. simplexui/__init__.py +53 -0
  5. simplexui/_version.py +1 -0
  6. simplexui/channelBox.py +858 -0
  7. simplexui/comboCheckDialog.py +343 -0
  8. simplexui/commands/__init__.py +16 -0
  9. simplexui/commands/alembicCommon.py +991 -0
  10. simplexui/commands/applyCorrectives.py +451 -0
  11. simplexui/commands/correctiveInterface.py +261 -0
  12. simplexui/commands/expandedExport.py +436 -0
  13. simplexui/commands/hdf5Convert.py +60 -0
  14. simplexui/commands/mayaCorrectiveInterface.py +161 -0
  15. simplexui/commands/mayatonumpy.py +375 -0
  16. simplexui/commands/mesh.py +1081 -0
  17. simplexui/commands/numpytoimath.py +319 -0
  18. simplexui/commands/poseblendlib.py +166 -0
  19. simplexui/commands/reorderSimplexPoints.py +102 -0
  20. simplexui/commands/rigidAlign.py +99 -0
  21. simplexui/commands/smpxBlend.py +629 -0
  22. simplexui/commands/unsubdivide.py +1227 -0
  23. simplexui/commands/uvTransfer.py +977 -0
  24. simplexui/dragFilter.py +299 -0
  25. simplexui/falloffDialog.py +471 -0
  26. simplexui/img/ChefHead.png +0 -0
  27. simplexui/img/frozen.png +0 -0
  28. simplexui/interface/__init__.py +28 -0
  29. simplexui/interface/dummyInterface.py +1585 -0
  30. simplexui/interface/mayaInterface.py +3271 -0
  31. simplexui/interfaceModel.py +1053 -0
  32. simplexui/interfaceModelTrees.py +441 -0
  33. simplexui/items/__init__.py +42 -0
  34. simplexui/items/accessor.py +213 -0
  35. simplexui/items/combo.py +852 -0
  36. simplexui/items/falloff.py +778 -0
  37. simplexui/items/group.py +297 -0
  38. simplexui/items/progression.py +743 -0
  39. simplexui/items/shape.py +443 -0
  40. simplexui/items/simplex.py +1764 -0
  41. simplexui/items/slider.py +738 -0
  42. simplexui/items/stack.py +154 -0
  43. simplexui/items/traversal.py +966 -0
  44. simplexui/main.pyw +22 -0
  45. simplexui/menu/__init__.py +69 -0
  46. simplexui/menu/dummyPlugins/__init__.py +16 -0
  47. simplexui/menu/genericPlugins/__init__.py +16 -0
  48. simplexui/menu/genericPlugins/_builtins.py +268 -0
  49. simplexui/menu/genericPlugins/checkPossibleCombos.py +45 -0
  50. simplexui/menu/genericPlugins/exportSplit.py +59 -0
  51. simplexui/menu/genericPlugins/showFalloffs.py +24 -0
  52. simplexui/menu/genericPlugins/showTraversals.py +24 -0
  53. simplexui/menu/genericPlugins/simplexUvTransfer.py +107 -0
  54. simplexui/menu/genericPlugins/unsubdivide.py +70 -0
  55. simplexui/menu/mayaPlugins/__init__.py +16 -0
  56. simplexui/menu/mayaPlugins/exportOther.py +43 -0
  57. simplexui/menu/mayaPlugins/extractProgressives.py +65 -0
  58. simplexui/menu/mayaPlugins/freezeCombo.py +245 -0
  59. simplexui/menu/mayaPlugins/generateShapeIncrementals.py +97 -0
  60. simplexui/menu/mayaPlugins/importObjs.py +193 -0
  61. simplexui/menu/mayaPlugins/linearizeTraversal.py +48 -0
  62. simplexui/menu/mayaPlugins/makeShelfBtn.py +65 -0
  63. simplexui/menu/mayaPlugins/relaxToSelection.py +75 -0
  64. simplexui/menu/mayaPlugins/reloadDefinition.py +33 -0
  65. simplexui/menu/mayaPlugins/snapToNeutral.py +72 -0
  66. simplexui/menu/mayaPlugins/softSelectToCluster.py +200 -0
  67. simplexui/menu/mayaPlugins/tweakMix.py +134 -0
  68. simplexui/menu/mayaPlugins/updateRestShape.py +105 -0
  69. simplexui/pysimplex.dll.a +0 -0
  70. simplexui/pysimplex.pyd +0 -0
  71. simplexui/simplexDialog.py +1454 -0
  72. simplexui/travCheckDialog.py +397 -0
  73. simplexui/traversalDialog.py +271 -0
  74. simplexui/ui/comboCheckDialog.ui +475 -0
  75. simplexui/ui/falloffDialog.ui +243 -0
  76. simplexui/ui/simplexDialog.ui +1458 -0
  77. simplexui/ui/travCheckDialog.ui +488 -0
  78. simplexui/ui/traversalDialog.ui +532 -0
  79. simplexui/utils.py +320 -0
@@ -0,0 +1,397 @@
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 itertools import combinations, product
19
+
20
+ from .dragFilter import DragFilter
21
+ from .items import Slider, Traversal
22
+ from Qt import QtCompat
23
+ from Qt.QtCore import Qt
24
+ from Qt.QtGui import QBrush, QColor
25
+ from Qt.QtWidgets import QDialog, QTreeWidgetItem
26
+ from .utils import getUiFile
27
+
28
+
29
+ class TooManyPossibilitiesError(Exception):
30
+ """Error raised when there are too many possibilities
31
+ Basically used as a stop-iteration
32
+ """
33
+
34
+ pass
35
+
36
+
37
+ def buildPossibleTraversals(
38
+ simplex, sliders, minDepth, maxDepth, lockDict=None, maxPoss=100
39
+ ):
40
+ """Build a list of possible traversals
41
+
42
+ Parameters
43
+ ----------
44
+ simplex : Simplex
45
+ The simplex system to check
46
+ sliders : Slider
47
+ The sliders to check
48
+ minDepth : int
49
+ The minimum number of sliders that will go into any traversals
50
+ maxDepth : int
51
+ The maximum number of sliders that will go into any traversals
52
+ lockDict : {Slider: ((float, ...), bool), ...}
53
+ An optional per-slider dict of possible values
54
+ maxPoss : float
55
+ The Maximum number of possibilities to return.(Default value = 100)
56
+
57
+ Returns
58
+ -------
59
+ : bool
60
+ True if the maximum number of possibilities was exceeded
61
+ : [([(Slider, (float, float)), ...], Traversal), ...]
62
+ Grouped slider/range pairs to existing (or None) Traversals
63
+ """
64
+ allRanges = {}
65
+ allDyn = {}
66
+ sliderDict = {}
67
+ lockDict = lockDict or {}
68
+
69
+ # Get the range values for each slider
70
+ for slider in sliders:
71
+ rng, dyn = lockDict.get(slider, (slider.prog.getRange(), True))
72
+ rng = set(rng)
73
+ rng.discard(0) # ignore the zeros
74
+ allRanges[slider] = sorted(rng)
75
+ allDyn[slider] = dyn
76
+ sliderDict[slider.name] = slider
77
+
78
+ poss = []
79
+ tooMany = False
80
+ try:
81
+ for size in range(minDepth, maxDepth + 1):
82
+ for grp in combinations(sliders, size):
83
+ names = [i.name for i in grp]
84
+ ranges = [allRanges[s] for s in grp]
85
+ for vals in product(*ranges):
86
+ for dynIdx in range(len(grp)):
87
+ if not allDyn[grp[dynIdx]]:
88
+ continue
89
+ trng = list(zip(vals, vals))
90
+ trng[dynIdx] = (0, trng[dynIdx][0])
91
+
92
+ count = Traversal.getCount(grp, trng)
93
+ if count == 0:
94
+ continue
95
+
96
+ poss.append(frozenset(list(zip(names, trng))))
97
+ if len(poss) > maxPoss:
98
+ raise TooManyPossibilitiesError("Don't melt your computer")
99
+ except TooManyPossibilitiesError:
100
+ tooMany = True
101
+
102
+ # Build a dict of traversals that already exist
103
+ # but only if their sliders are in the list of sliders to check
104
+ onlys = {}
105
+ for trav in simplex.traversals:
106
+ sls = trav.allSliders()
107
+ if all(r in sliders for r in sls):
108
+ rngs = trav.ranges()
109
+ key = frozenset([(k.name, v) for k, v in rngs.items()])
110
+ onlys[key] = trav
111
+
112
+ toAdd = []
113
+ for p in poss:
114
+ truePairs = [(sliderDict[n], r) for n, r in p]
115
+ toAdd.append((truePairs, onlys.get(p)))
116
+ return tooMany, toAdd
117
+
118
+
119
+ class TravCheckItem(QTreeWidgetItem):
120
+ def __init__(self, pairs, trav, *args, **kwargs):
121
+ super(TravCheckItem, self).__init__(*args, **kwargs)
122
+ self.pairs = pairs
123
+ self.trav = trav
124
+
125
+ exists = False
126
+ grayBrush = QBrush(QColor(128, 128, 128))
127
+ if self.trav is None:
128
+ ranges = dict(self.pairs)
129
+ newName = Traversal.buildTraversalName(ranges)
130
+ self.setText(0, newName)
131
+ else:
132
+ exists = True
133
+ self.setText(0, self.trav.name)
134
+ self.setForeground(0, grayBrush)
135
+ self.setForeground(1, grayBrush)
136
+ self.setForeground(2, grayBrush)
137
+
138
+ # create the slider sub-rows
139
+ for slider, rng in pairs:
140
+ item = QTreeWidgetItem(self)
141
+
142
+ item.setData(0, Qt.ItemDataRole.EditRole, slider.name)
143
+ item.setData(1, Qt.ItemDataRole.EditRole, rng[0])
144
+ item.setData(2, Qt.ItemDataRole.EditRole, rng[1])
145
+ if exists:
146
+ item.setForeground(0, grayBrush)
147
+ item.setForeground(1, grayBrush)
148
+ item.setForeground(2, grayBrush)
149
+
150
+ self.setExpanded(True)
151
+
152
+
153
+ class TraversalCheckDialog(QDialog):
154
+ """Dialog for checking what possible traversals exist, and picking new traversals
155
+ In 'Create' mode, it provides a quick way of choosing the one specific traversal
156
+ that the user is looking for
157
+
158
+ In 'Check' mode, it provides a convenient way to explore the possibilites
159
+ and create any missing traversals directly
160
+
161
+ Parameters
162
+ ----------
163
+ sliders : [Slider, ...]
164
+ A list of sliders to check
165
+ values : {Slider: (float, ...), ...}
166
+ A dictionary of values to use per slider
167
+ mode : str
168
+ The mode to display the dialog. Defaults to 'create'
169
+ parent : QObject
170
+ The Parent of the dialog. Must be a SimplexDialog
171
+
172
+ Returns
173
+ -------
174
+ """
175
+
176
+ def __init__(
177
+ self,
178
+ sliders,
179
+ values=None,
180
+ dynamics=None,
181
+ mode="create",
182
+ parent=None,
183
+ grandparent=None,
184
+ ):
185
+ super(TraversalCheckDialog, self).__init__(parent)
186
+
187
+ uiPath = getUiFile(__file__)
188
+ QtCompat.loadUi(uiPath, self)
189
+ self.mode = mode.lower()
190
+
191
+ # Store the Parent UI rather than relying on Qt's .parent()
192
+ # Could cause crashes otherwise
193
+ self.parUI = parent
194
+ self.gparUI = grandparent
195
+ self.maxPoss = 100
196
+ self.colCheckRoles = [
197
+ Qt.ItemDataRole.UserRole,
198
+ Qt.ItemDataRole.UserRole,
199
+ Qt.ItemDataRole.UserRole,
200
+ Qt.ItemDataRole.EditRole,
201
+ ]
202
+
203
+ self.uiCreateSelectedBTN.clicked.connect(self.createMissing)
204
+ self.uiMinLimitSPIN.valueChanged.connect(self.populateWithoutUpdate)
205
+ self.uiMaxLimitSPIN.valueChanged.connect(self.populateWithoutUpdate)
206
+ self.uiCancelBTN.clicked.connect(self.close)
207
+ self.uiManualUpdateBTN.clicked.connect(self.populateWithUpdate)
208
+ self.uiEditTREE.itemChanged.connect(self.populateWithoutUpdate)
209
+
210
+ self.dragFilter = DragFilter(self)
211
+ self.uiEditTREE.viewport().installEventFilter(self.dragFilter)
212
+ self.dragFilter.dragTick.connect(self.dragTick)
213
+
214
+ self.gparUI.uiSliderTREE.selectionModel().selectionChanged.connect(
215
+ self.populateWithCheck
216
+ )
217
+
218
+ self.valueDict = values or {}
219
+ self.dynDict = dynamics or {}
220
+ self.setSliders(sliders)
221
+ if self.mode == "create":
222
+ self.uiAutoUpdateCHK.setCheckState(Qt.CheckState.Unchecked)
223
+ self.uiAutoUpdateCHK.hide()
224
+ self.uiManualUpdateBTN.hide()
225
+
226
+ self.uiMaxLimitSPIN.setValue(max(len(sliders), 2))
227
+ self.uiMinLimitSPIN.setValue(max(len(sliders) - 2, 2))
228
+
229
+ if sliders is None:
230
+ self.populateWithUpdate()
231
+ else:
232
+ self._populate()
233
+
234
+ def dragTick(self, ticks, mul):
235
+ """Deal with the ticks coming from the drag handler
236
+
237
+ Parameters
238
+ ----------
239
+ ticks : int
240
+ The number of ticks since the last update
241
+ mul : float
242
+ The multiplier value from the drag handler
243
+
244
+ Returns
245
+ -------
246
+
247
+ """
248
+ items = self.uiEditTREE.selectedItems()
249
+ for item in items:
250
+ val = item.data(3, Qt.ItemDataRole.EditRole)
251
+ val += (0.05) * ticks * mul
252
+ if abs(val) < 1.0e-5:
253
+ val = 0.0
254
+ val = max(min(val, 1.0), -1.0)
255
+ item.setData(3, Qt.ItemDataRole.EditRole, val)
256
+ self.uiEditTREE.viewport().update()
257
+
258
+ def setSliders(self, val):
259
+ """Set the sliders displayed in this UI
260
+
261
+ Parameters
262
+ ----------
263
+ val : [Slider, ...]
264
+ The sliders to be displayed
265
+
266
+ Returns
267
+ -------
268
+
269
+ """
270
+ self.uiEditTREE.clear()
271
+ dvs = [None, -1.0, 1.0, 0.5]
272
+ val = val or []
273
+ for slider in val:
274
+ item = QTreeWidgetItem(self.uiEditTREE, [slider.name])
275
+ item.setFlags(item.flags() | Qt.ItemFlag.ItemIsEditable)
276
+ rangeVals = self.valueDict.get(slider, [-1.0, 1.0])
277
+
278
+ item.setData(0, Qt.ItemDataRole.UserRole, slider)
279
+ for col in range(1, 3):
280
+ val = dvs[col]
281
+ item.setData(col, self.colCheckRoles[col], val)
282
+ rng = slider.prog.getRange()
283
+ if val in rng:
284
+ chk = (
285
+ Qt.CheckState.Checked
286
+ if val in rangeVals
287
+ else Qt.CheckState.Unchecked
288
+ )
289
+ item.setCheckState(col, chk)
290
+ item.setCheckState(3, self.dynDict.get(slider, Qt.CheckState.Checked))
291
+
292
+ for col in reversed(list(range(4))):
293
+ self.uiEditTREE.resizeColumnToContents(col)
294
+
295
+ def closeEvent(self, event):
296
+ """Override the Qt close event"""
297
+ self.gparUI.uiSliderTREE.selectionModel().selectionChanged.disconnect(
298
+ self.populateWithCheck
299
+ )
300
+ super(TraversalCheckDialog, self).closeEvent(event)
301
+
302
+ def populateWithUpdate(self):
303
+ """Populate the list from the main dialog selection"""
304
+ self.setSliders(self.gparUI.uiSliderTREE.getSelectedItems(typ=Slider))
305
+ self._populate()
306
+
307
+ def populateWithoutUpdate(self):
308
+ """Populate the list and but don't look at the main dialog"""
309
+ self._populate()
310
+
311
+ def populateWithCheck(self):
312
+ """Populate the list from the main dialog selection, only if the AutoUpdate checkbox is checked"""
313
+ if self.uiAutoUpdateCHK.isChecked():
314
+ self.setSliders(self.gparUI.uiSliderTREE.getSelectedItems(typ=Slider))
315
+ self._populate()
316
+
317
+ def _populate(self):
318
+ """Populate the list widgets in the UI"""
319
+ minDepth = self.uiMinLimitSPIN.value()
320
+ maxDepth = self.uiMaxLimitSPIN.value()
321
+
322
+ root = self.uiEditTREE.invisibleRootItem()
323
+ lockDict = {}
324
+ sliderList = []
325
+
326
+ for row in range(root.childCount()):
327
+ item = root.child(row)
328
+ slider = item.data(0, Qt.ItemDataRole.UserRole)
329
+ if slider is not None:
330
+ sliderList.append(slider)
331
+ lv = [
332
+ item.data(col, self.colCheckRoles[col])
333
+ for col in range(1, 3)
334
+ if item.checkState(col) == Qt.CheckState.Checked
335
+ ]
336
+ dyn = item.checkState(3) == Qt.CheckState.Checked
337
+ lockDict[slider] = (lv, dyn)
338
+
339
+ tooMany, toAdd = buildPossibleTraversals(
340
+ self.parUI.simplex,
341
+ sliderList,
342
+ minDepth,
343
+ maxDepth,
344
+ lockDict=lockDict,
345
+ maxPoss=self.maxPoss,
346
+ )
347
+
348
+ lbl = (
349
+ "Too many possibilities. Limiting to {0}".format(self.maxPoss)
350
+ if tooMany
351
+ else ""
352
+ )
353
+ self.uiWarningLBL.setText(lbl)
354
+
355
+ self.uiTravCheckTREE.clear()
356
+ for pairs, trav in reversed(toAdd):
357
+ TravCheckItem(pairs, trav, self.uiTravCheckTREE)
358
+
359
+ for i in reversed(list(range(self.uiTravCheckTREE.columnCount()))):
360
+ self.uiTravCheckTREE.resizeColumnToContents(i)
361
+
362
+ if self.mode == "create":
363
+ if self.uiTravCheckTREE.topLevelItemCount() > 0:
364
+ self.uiTravCheckTREE.topLevelItem(0).setSelected(True)
365
+
366
+ def createMissing(self):
367
+ """Create selected traversals if they don't already exist"""
368
+ simplex = self.parUI.simplex
369
+ created = []
370
+
371
+ tops = []
372
+ for item in self.uiTravCheckTREE.selectedItems():
373
+ par = item.parent()
374
+ if par is not None:
375
+ item = par
376
+ if item not in tops:
377
+ tops.append(item)
378
+
379
+ for item in tops:
380
+ name = item.text(0)
381
+ sliders, ranges = list(zip(*item.pairs))
382
+ # Double check that the user didn't create any extra sliders
383
+ if Traversal.traversalAlreadyExists(simplex, sliders, ranges) is None:
384
+ count = Traversal.getCount(sliders, ranges)
385
+ startPairs, endPairs = list(
386
+ zip(*[((s, a), (s, b)) for s, (a, b) in item.pairs])
387
+ )
388
+ t = Traversal.createTraversal(
389
+ name, simplex, startPairs, endPairs, count=count
390
+ )
391
+ created.append(t)
392
+
393
+ self.parUI.uiTraversalTREE.setItemSelection(created)
394
+ if self.mode == "create":
395
+ self.close()
396
+ else:
397
+ self.populateWithoutUpdate()
@@ -0,0 +1,271 @@
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
+
19
+ # Ignore a bunch of linter warnings that show up because of my choice of abstraction
20
+ # pylint: disable=unused-argument,too-many-public-methods,relative-import
21
+ # pylint: disable=too-many-statements,no-self-use,missing-docstring
22
+ import re
23
+
24
+ from .interface import DCC
25
+ from .interfaceModel import (
26
+ TraversalFilterModel,
27
+ TraversalModel,
28
+ coerceIndexToRoots,
29
+ coerceIndexToType,
30
+ )
31
+ from .interfaceModelTrees import TraversalTree
32
+ from .items import Group, Simplex, Slider, Traversal, TravPair
33
+
34
+ # This module imports QT from PyQt4, PySide or PySide2
35
+ # Depending on what's available
36
+ from Qt import QtCompat
37
+ from Qt.QtGui import QStandardItemModel
38
+ from Qt.QtWidgets import (
39
+ QApplication,
40
+ QDialog,
41
+ QInputDialog,
42
+ QMessageBox,
43
+ QProgressDialog,
44
+ )
45
+ from .travCheckDialog import TraversalCheckDialog
46
+ from .utils import getUiFile, makeUnique
47
+
48
+ NAME_CHECK = re.compile(r"[A-Za-z][\w.]*")
49
+
50
+
51
+ class TraversalDialog(QDialog):
52
+ """The dialog for dealing with Traversals
53
+
54
+ Parameters
55
+ ----------
56
+ parent : SimplexDialog
57
+ The parent simplex dialog
58
+ """
59
+
60
+ def __init__(self, parent):
61
+ super(TraversalDialog, self).__init__(parent)
62
+
63
+ uiPath = getUiFile(__file__)
64
+ QtCompat.loadUi(uiPath, self)
65
+ self.parUI = parent
66
+
67
+ # Load the custom tree manually
68
+ self.uiTraversalTREE = TraversalTree(self)
69
+ self.uiTraversalTREE.setDragEnabled(False)
70
+ self.uiTraversalTREE.setDragDropMode(TraversalTree.NoDragDrop)
71
+ self.uiTraversalTREE.setSelectionMode(TraversalTree.ExtendedSelection)
72
+ self.uiTraversalTREE.dragFilter.dragPressed.connect(self.dragStart)
73
+ self.uiTraversalTREE.dragFilter.dragReleased.connect(self.dragStop)
74
+
75
+ self.uiTraversalLAY.addWidget(self.uiTraversalTREE)
76
+ self.simplex = None
77
+ self.parUI.simplexLoaded.connect(self.loadSimplex)
78
+
79
+ self.uiTravDeleteBTN.clicked.connect(self.deleteTrav)
80
+ self.uiTravNewBTN.clicked.connect(self.newTrav)
81
+ self.uiTravNewGroupBTN.clicked.connect(self.newGroup)
82
+ self.uiTravNewShapeBTN.clicked.connect(self.newShape)
83
+ self.uiTravAddSliderBTN.clicked.connect(self.addSlider)
84
+ self.uiShapeExtractBTN.clicked.connect(self.shapeExtract)
85
+ self.uiShapeConnectBTN.clicked.connect(self.shapeConnectFromSelection)
86
+
87
+ self.parUI.uiHideRedundantACT.toggled.connect(self.hideRedundant)
88
+
89
+ self.loadSimplex()
90
+
91
+ def hideRedundant(self):
92
+ """Hide Redundant items in the ui based on the checkbox"""
93
+ check = self.uiHideRedundantACT.isChecked()
94
+ travModel = self.uiTraversalTREE.model()
95
+ travModel.doFilter = check
96
+ travModel.invalidateFilter()
97
+
98
+ def dragStart(self):
99
+ """Slot for handling the start of a MMB Drag event"""
100
+ if self.simplex is not None:
101
+ self.simplex.DCC.undoOpen()
102
+
103
+ def dragStop(self):
104
+ """Slot for handling the end of a MMB Drag event"""
105
+ if self.simplex is not None:
106
+ self.simplex.DCC.undoClose()
107
+
108
+ def loadSimplex(self):
109
+ """Load the simplex system from the parent dialog"""
110
+ system = self.parUI.simplex
111
+ if system is None:
112
+ self.simplex = system
113
+ self.uiTraversalTREE.setModel(QStandardItemModel())
114
+
115
+ self.uiTravDeleteBTN.setEnabled(False)
116
+ self.uiTravNewBTN.setEnabled(False)
117
+ self.uiTravNewGroupBTN.setEnabled(False)
118
+ self.uiTravNewShapeBTN.setEnabled(False)
119
+ self.uiTravAddSliderBTN.setEnabled(False)
120
+ self.uiShapeExtractBTN.setEnabled(False)
121
+ self.uiShapeConnectBTN.setEnabled(False)
122
+ return
123
+ else:
124
+ self.uiTravDeleteBTN.setEnabled(True)
125
+ self.uiTravNewBTN.setEnabled(True)
126
+ self.uiTravNewGroupBTN.setEnabled(True)
127
+ self.uiTravNewShapeBTN.setEnabled(True)
128
+ self.uiTravAddSliderBTN.setEnabled(True)
129
+ self.uiShapeExtractBTN.setEnabled(True)
130
+ self.uiShapeConnectBTN.setEnabled(True)
131
+
132
+ if system == self.simplex:
133
+ return
134
+
135
+ self.simplex = system
136
+
137
+ sliderProxyModel = self.parUI.uiSliderTREE.model()
138
+ if not sliderProxyModel:
139
+ self.uiTraversalTREE.setModel(None)
140
+ return
141
+ sliderModel = sliderProxyModel.sourceModel()
142
+ simplexModel = sliderModel.sourceModel()
143
+
144
+ travModel = TraversalModel(simplexModel)
145
+ travProxModel = TraversalFilterModel(travModel)
146
+ self.uiTraversalTREE.setModel(travProxModel)
147
+
148
+ def deleteTrav(self):
149
+ """Delete the selected traversals"""
150
+ idxs = self.uiTraversalTREE.getSelectedIndexes()
151
+ roots = coerceIndexToRoots(idxs)
152
+ if not roots:
153
+ QMessageBox.warning(self, "Warning", "Nothing Selected")
154
+ return
155
+ roots = makeUnique([i.model().itemFromIndex(i) for i in roots])
156
+ for r in roots:
157
+ if isinstance(r, Simplex):
158
+ QMessageBox.warning(
159
+ self, "Warning", "Cannot delete a simplex system this way (for now)"
160
+ )
161
+ return
162
+
163
+ pairs = [r for r in roots if isinstance(r, TravPair)]
164
+ roots = [r for r in roots if not isinstance(r, TravPair)]
165
+
166
+ for r in roots:
167
+ r.delete()
168
+
169
+ TravPair.removeAll(pairs)
170
+
171
+ self.uiTraversalTREE.model().invalidateFilter()
172
+
173
+ def newGroup(self):
174
+ """Create a new group for organizing the traversals"""
175
+ if self.simplex is None:
176
+ return
177
+ newName, good = QInputDialog.getText(
178
+ self, "New Group", "Enter a name for the new group", text="Group"
179
+ )
180
+ if not good:
181
+ return
182
+ if not NAME_CHECK.match(newName):
183
+ message = "Group name can only contain letters and numbers, and cannot start with a number"
184
+ QMessageBox.warning(self, "Warning", message)
185
+ return
186
+
187
+ items = self.uiTraversalTREE.getSelectedItems(Slider)
188
+ Group.createGroup(str(newName), self.simplex, items)
189
+
190
+ def newShape(self):
191
+ """Add a new shape to the traversal's Progression"""
192
+ pars = self.uiTraversalTREE.getSelectedIndexes()
193
+ if not pars:
194
+ return
195
+ travs = coerceIndexToType(pars, Traversal)
196
+ for travIdx in travs:
197
+ trav = travIdx.model().itemFromIndex(travIdx)
198
+ trav.prog.createShape()
199
+
200
+ def shapeExtract(self):
201
+ """Extract a shape from the traversal's progression"""
202
+ indexes = self.uiTraversalTREE.getSelectedIndexes()
203
+ return self.parUI.shapeIndexExtract(indexes)
204
+
205
+ def newTrav(self):
206
+ """Create a new traversal based on the selection in the main UI"""
207
+ sliders = self.parUI.uiSliderTREE.getSelectedItems(Slider)
208
+ if len(sliders) < 2:
209
+ message = "Must have at least 2 sliders selected"
210
+ QMessageBox.warning(self, "Warning", message)
211
+ return None
212
+
213
+ tcd = TraversalCheckDialog(
214
+ sliders, mode="create", parent=self, grandparent=self.parUI
215
+ )
216
+ tcd.move(self.pos())
217
+ tcd.exec_()
218
+
219
+ def addSlider(self):
220
+ """Add a slider to the traversal's definition"""
221
+ # add the slider to both the start and end
222
+ travs = self.uiTraversalTREE.getSelectedItems(Traversal)
223
+ sliders = self.parUI.uiSliderTREE.getSelectedItems(Slider)
224
+ if not travs:
225
+ return
226
+ if not sliders:
227
+ return
228
+ for slider in sliders:
229
+ travs[-1].addSlider(slider)
230
+
231
+ def shapeConnectFromSelection(self):
232
+ """Connect a shape into the traversal based on the DCC scene selection"""
233
+ if self.simplex is None:
234
+ return
235
+ # make a dict of name:object
236
+ sel = DCC.getSelectedObjects()
237
+ selDict = {}
238
+ for s in sel:
239
+ name = DCC.getObjectName(s)
240
+ if name.endswith("_Extract"):
241
+ nn = name.rsplit("_Extract", 1)[0]
242
+ selDict[nn] = s
243
+
244
+ pairDict = {}
245
+ for p in self.simplex.progs:
246
+ for pp in p.pairs:
247
+ pairDict[pp.shape.name] = pp
248
+
249
+ # get all common names
250
+ common = selDict.keys() & pairDict.keys()
251
+
252
+ # get those items
253
+ pairs = [pairDict[i] for i in common]
254
+
255
+ # Set up the progress bar
256
+ pBar = QProgressDialog("Connecting Shapes", "Cancel", 0, 100, self)
257
+ pBar.setMaximum(len(pairs))
258
+
259
+ # Do the extractions
260
+ for pair in pairs:
261
+ c = pair.prog.controller
262
+ c.connectShape(pair.shape, delete=True)
263
+
264
+ # ProgressBar
265
+ pBar.setValue(pBar.value() + 1)
266
+ pBar.setLabelText("Connecting:\n{0}".format(pair.shape.name))
267
+ QApplication.processEvents()
268
+ if pBar.wasCanceled():
269
+ return
270
+
271
+ pBar.close()