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