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