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.
- simplex_solver-3.2.2.dist-info/DELVEWHEEL +2 -0
- simplex_solver-3.2.2.dist-info/METADATA +94 -0
- simplex_solver-3.2.2.dist-info/RECORD +84 -0
- simplex_solver-3.2.2.dist-info/WHEEL +5 -0
- simplex_solver.libs/.load-order-simplex_solver-3.2.2 +1 -0
- simplex_solver.libs/msvcp140-a4c2229bdc2a2a630acdc095b4d86008.dll +0 -0
- simplexui/__init__.py +86 -0
- simplexui/_version.py +1 -0
- simplexui/channelBox.py +867 -0
- simplexui/comboCheckDialog.py +396 -0
- simplexui/commands/__init__.py +16 -0
- simplexui/commands/alembicCommon.py +1148 -0
- simplexui/commands/alembic_walker.py +299 -0
- simplexui/commands/applyCorrectives.py +452 -0
- simplexui/commands/correctiveInterface.py +259 -0
- simplexui/commands/expandedExport.py +434 -0
- simplexui/commands/hdf5Convert.py +62 -0
- simplexui/commands/mayaCorrectiveInterface.py +159 -0
- simplexui/commands/mayatonumpy.py +416 -0
- simplexui/commands/mesh.py +1085 -0
- simplexui/commands/poseblendlib.py +168 -0
- simplexui/commands/reorderSimplexPoints.py +102 -0
- simplexui/commands/replaceDefinitionJson.py +74 -0
- simplexui/commands/rigidAlign.py +97 -0
- simplexui/commands/unsubdivide.py +1222 -0
- simplexui/commands/uvTransfer.py +976 -0
- simplexui/dragFilter.py +334 -0
- simplexui/falloffDialog.py +504 -0
- simplexui/img/ChefHead.png +0 -0
- simplexui/img/frozen.png +0 -0
- simplexui/interface/__init__.py +30 -0
- simplexui/interface/dummyInterface.py +1313 -0
- simplexui/interface/mayaInterface.py +2294 -0
- simplexui/interfaceModel.py +655 -0
- simplexui/interfaceModelTrees.py +456 -0
- simplexui/items/__init__.py +50 -0
- simplexui/items/accessor.py +145 -0
- simplexui/items/combo.py +645 -0
- simplexui/items/dragItem.py +44 -0
- simplexui/items/falloff.py +748 -0
- simplexui/items/group.py +267 -0
- simplexui/items/progression.py +613 -0
- simplexui/items/shape.py +384 -0
- simplexui/items/simplex.py +1734 -0
- simplexui/items/slider.py +632 -0
- simplexui/items/stack.py +147 -0
- simplexui/items/traversal.py +780 -0
- simplexui/items/treeItem.py +441 -0
- simplexui/main.pyw +22 -0
- simplexui/menu/__init__.py +73 -0
- simplexui/menu/dummyPlugins/__init__.py +16 -0
- simplexui/menu/genericPlugins/__init__.py +16 -0
- simplexui/menu/genericPlugins/_builtins.py +270 -0
- simplexui/menu/genericPlugins/checkPossibleCombos.py +48 -0
- simplexui/menu/genericPlugins/exportSplit.py +67 -0
- simplexui/menu/genericPlugins/showFalloffs.py +26 -0
- simplexui/menu/genericPlugins/showTraversals.py +26 -0
- simplexui/menu/genericPlugins/simplexUvTransfer.py +106 -0
- simplexui/menu/genericPlugins/unsubdivide.py +72 -0
- simplexui/menu/mayaPlugins/__init__.py +16 -0
- simplexui/menu/mayaPlugins/exportOther.py +53 -0
- simplexui/menu/mayaPlugins/extractProgressives.py +68 -0
- simplexui/menu/mayaPlugins/freezeCombo.py +247 -0
- simplexui/menu/mayaPlugins/generateShapeIncrementals.py +99 -0
- simplexui/menu/mayaPlugins/importObjs.py +199 -0
- simplexui/menu/mayaPlugins/linearizeTraversal.py +60 -0
- simplexui/menu/mayaPlugins/makeShelfBtn.py +67 -0
- simplexui/menu/mayaPlugins/relaxToSelection.py +76 -0
- simplexui/menu/mayaPlugins/reloadDefinition.py +44 -0
- simplexui/menu/mayaPlugins/snapToNeutral.py +71 -0
- simplexui/menu/mayaPlugins/softSelectToCluster.py +201 -0
- simplexui/menu/mayaPlugins/tweakMix.py +136 -0
- simplexui/menu/mayaPlugins/updateRestShape.py +113 -0
- simplexui/pysimplex.lib +0 -0
- simplexui/pysimplex.pyd +0 -0
- simplexui/simplexDialog.py +1547 -0
- simplexui/travCheckDialog.py +419 -0
- simplexui/traversalDialog.py +299 -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 +307 -0
|
@@ -0,0 +1,655 @@
|
|
|
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
|
+
import re
|
|
21
|
+
from typing import Any, TypeVar, cast
|
|
22
|
+
|
|
23
|
+
from Qt.QtCore import QModelIndex, QSortFilterProxyModel, Qt
|
|
24
|
+
from Qt.QtWidgets import QWidget
|
|
25
|
+
|
|
26
|
+
from .items import (
|
|
27
|
+
Combo,
|
|
28
|
+
ComboPair,
|
|
29
|
+
Falloff,
|
|
30
|
+
Group,
|
|
31
|
+
ProgPair,
|
|
32
|
+
Progression,
|
|
33
|
+
Simplex,
|
|
34
|
+
Slider,
|
|
35
|
+
Traversal,
|
|
36
|
+
TravPair,
|
|
37
|
+
)
|
|
38
|
+
from .items.treeItem import AdapterModel, TreeItem, TreeRootItem
|
|
39
|
+
|
|
40
|
+
T = TypeVar('T', bound=TreeItem)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# Hierarchy Helpers
|
|
44
|
+
def coerceIndexToType(indexes: list[QModelIndex], typ: type[T]) -> list[QModelIndex]:
|
|
45
|
+
"""Get a list of indices of a specific type based on a given index list
|
|
46
|
+
Items containing parents of the type fall down to their children
|
|
47
|
+
Items containing children of the type climb up to their parents
|
|
48
|
+
|
|
49
|
+
Parameters
|
|
50
|
+
----------
|
|
51
|
+
indexes : [QModelIndex, ...]
|
|
52
|
+
A list of indexes to coerce
|
|
53
|
+
typ : Type
|
|
54
|
+
The type to coerce to
|
|
55
|
+
|
|
56
|
+
Returns
|
|
57
|
+
-------
|
|
58
|
+
[QModelIndex, ...]
|
|
59
|
+
The coerced list
|
|
60
|
+
"""
|
|
61
|
+
targetDepth = typ.classDepth
|
|
62
|
+
|
|
63
|
+
children = []
|
|
64
|
+
parents = []
|
|
65
|
+
out = []
|
|
66
|
+
for idx in indexes:
|
|
67
|
+
item = idx.model().itemFromIndex(idx)
|
|
68
|
+
depth = item.classDepth
|
|
69
|
+
if depth < targetDepth:
|
|
70
|
+
parents.append(idx)
|
|
71
|
+
elif depth > targetDepth:
|
|
72
|
+
children.append(idx)
|
|
73
|
+
else:
|
|
74
|
+
out.append(idx)
|
|
75
|
+
|
|
76
|
+
out.extend(coerceIndexToChildType(parents, typ))
|
|
77
|
+
out.extend(coerceIndexToParentType(children, typ))
|
|
78
|
+
out = list(set(out))
|
|
79
|
+
return out
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def coerceIndexToChildType(
|
|
83
|
+
indexes: list[QModelIndex], typ: type[T]
|
|
84
|
+
) -> list[QModelIndex]:
|
|
85
|
+
"""Get a list of indices of a specific type based on a given index list
|
|
86
|
+
Lists containing parents of the type fall down to their children
|
|
87
|
+
|
|
88
|
+
Parameters
|
|
89
|
+
----------
|
|
90
|
+
indexes : [QModelIndex, ...]
|
|
91
|
+
A list of indexes to coerce
|
|
92
|
+
typ : Type
|
|
93
|
+
The type to coerce to
|
|
94
|
+
|
|
95
|
+
Returns
|
|
96
|
+
-------
|
|
97
|
+
[QModelIndex, ...]
|
|
98
|
+
The coerced list
|
|
99
|
+
"""
|
|
100
|
+
targetDepth = typ.classDepth
|
|
101
|
+
out = []
|
|
102
|
+
|
|
103
|
+
for idx in indexes:
|
|
104
|
+
model = idx.model()
|
|
105
|
+
item = idx.model().itemFromIndex(idx)
|
|
106
|
+
if item.classDepth < targetDepth:
|
|
107
|
+
# Too high up, grab children
|
|
108
|
+
queue = [idx]
|
|
109
|
+
depthIdxs = []
|
|
110
|
+
while queue:
|
|
111
|
+
checkIdx = queue.pop()
|
|
112
|
+
checkItem = checkIdx.model().itemFromIndex(checkIdx)
|
|
113
|
+
if checkItem.classDepth < targetDepth:
|
|
114
|
+
for row in range(model.rowCount(checkIdx)):
|
|
115
|
+
queue.append(model.index(row, 0, checkIdx))
|
|
116
|
+
elif checkItem.classDepth == targetDepth:
|
|
117
|
+
depthIdxs.append(checkIdx)
|
|
118
|
+
out.extend(depthIdxs)
|
|
119
|
+
elif item.classDepth == targetDepth:
|
|
120
|
+
out.append(idx)
|
|
121
|
+
|
|
122
|
+
out = list(set(out))
|
|
123
|
+
return out
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def coerceIndexToParentType(
|
|
127
|
+
indexes: list[QModelIndex], typ: type[T]
|
|
128
|
+
) -> list[QModelIndex]:
|
|
129
|
+
"""Get a list of indices of a specific type based on a given index list
|
|
130
|
+
Lists containing children of the type climb up to their parents
|
|
131
|
+
|
|
132
|
+
Parameters
|
|
133
|
+
----------
|
|
134
|
+
indexes : [QModelIndex, ...]
|
|
135
|
+
A list of indexes to coerce
|
|
136
|
+
typ : Type
|
|
137
|
+
The type to coerce to
|
|
138
|
+
|
|
139
|
+
Returns
|
|
140
|
+
-------
|
|
141
|
+
[QModelIndex, ...]
|
|
142
|
+
The coerced list
|
|
143
|
+
"""
|
|
144
|
+
targetDepth = typ.classDepth
|
|
145
|
+
out = []
|
|
146
|
+
for idx in indexes:
|
|
147
|
+
item = idx.model().itemFromIndex(idx)
|
|
148
|
+
depth = item.classDepth
|
|
149
|
+
if depth > targetDepth:
|
|
150
|
+
parIdx = idx
|
|
151
|
+
parItem = parIdx.model().itemFromIndex(parIdx)
|
|
152
|
+
while parItem.classDepth > targetDepth:
|
|
153
|
+
parIdx = parIdx.parent()
|
|
154
|
+
parItem = parIdx.model().itemFromIndex(parIdx)
|
|
155
|
+
if parItem.classDepth == targetDepth:
|
|
156
|
+
out.append(parIdx)
|
|
157
|
+
elif depth == targetDepth:
|
|
158
|
+
out.append(idx)
|
|
159
|
+
|
|
160
|
+
out = list(set(out))
|
|
161
|
+
return out
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def coerceIndexToRoots(indexes: list[QModelIndex]) -> list[QModelIndex]:
|
|
165
|
+
"""Get the topmost indexes for each brach in the hierarchy
|
|
166
|
+
|
|
167
|
+
Parameters
|
|
168
|
+
----------
|
|
169
|
+
indexes : [QModelIndex, ...]
|
|
170
|
+
A list of indexes to coerce
|
|
171
|
+
|
|
172
|
+
Returns
|
|
173
|
+
-------
|
|
174
|
+
[QModelIndex, ...]
|
|
175
|
+
The coerced list
|
|
176
|
+
"""
|
|
177
|
+
indexes = [i for i in indexes if i.column() == 0]
|
|
178
|
+
indexes = sorted(
|
|
179
|
+
indexes, key=lambda x: x.model().itemFromIndex(x).classDepth, reverse=True
|
|
180
|
+
)
|
|
181
|
+
# Check each item to see if any of it's ancestors
|
|
182
|
+
# are in the selection list. If not, it's a root
|
|
183
|
+
roots = []
|
|
184
|
+
for idx in indexes:
|
|
185
|
+
par = idx.parent()
|
|
186
|
+
while par.isValid():
|
|
187
|
+
if par in indexes:
|
|
188
|
+
break
|
|
189
|
+
par = par.parent()
|
|
190
|
+
else:
|
|
191
|
+
roots.append(idx)
|
|
192
|
+
|
|
193
|
+
return roots
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
# BASE MODEL
|
|
197
|
+
class SimplexModel(AdapterModel):
|
|
198
|
+
"""The base model for all interaction with a simplex system.
|
|
199
|
+
All ui interactions with a simplex system must go through this model
|
|
200
|
+
Any special requirements, or reorganizations of the trees will only
|
|
201
|
+
be implemented as proxy models.
|
|
202
|
+
|
|
203
|
+
There will be little documentation for this class, as all methods
|
|
204
|
+
are virtual overrides of the underlying Qt class
|
|
205
|
+
|
|
206
|
+
Parameters
|
|
207
|
+
----------
|
|
208
|
+
simplex : Simplex
|
|
209
|
+
The Simplex system for this model
|
|
210
|
+
parent : QObject
|
|
211
|
+
The parent for this model
|
|
212
|
+
|
|
213
|
+
"""
|
|
214
|
+
|
|
215
|
+
@property
|
|
216
|
+
def simplex(self) -> TreeRootItem | None:
|
|
217
|
+
return self._rootItem
|
|
218
|
+
|
|
219
|
+
def headerData(
|
|
220
|
+
self, section: int, orientation: Qt.Orientation, role: int
|
|
221
|
+
) -> str | None:
|
|
222
|
+
if orientation == Qt.Orientation.Horizontal:
|
|
223
|
+
if role == Qt.ItemDataRole.DisplayRole:
|
|
224
|
+
sects = ("Items", "Slide", "Value")
|
|
225
|
+
return sects[section]
|
|
226
|
+
return None
|
|
227
|
+
|
|
228
|
+
def flags(self, index: QModelIndex) -> Qt.ItemFlag:
|
|
229
|
+
if not index.isValid():
|
|
230
|
+
return Qt.ItemFlag.ItemIsEnabled
|
|
231
|
+
if index.column() == 0:
|
|
232
|
+
item = index.internalPointer()
|
|
233
|
+
if isinstance(item, (Slider, Combo, Traversal)):
|
|
234
|
+
return (
|
|
235
|
+
Qt.ItemFlag.ItemIsEnabled
|
|
236
|
+
| Qt.ItemFlag.ItemIsSelectable
|
|
237
|
+
| Qt.ItemFlag.ItemIsEditable
|
|
238
|
+
| Qt.ItemFlag.ItemIsUserCheckable
|
|
239
|
+
)
|
|
240
|
+
elif isinstance(item, Progression):
|
|
241
|
+
return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable
|
|
242
|
+
return (
|
|
243
|
+
Qt.ItemFlag.ItemIsEnabled
|
|
244
|
+
| Qt.ItemFlag.ItemIsSelectable
|
|
245
|
+
| Qt.ItemFlag.ItemIsEditable
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
def setData(
|
|
249
|
+
self, index: QModelIndex, value: Any, role: int = Qt.ItemDataRole.EditRole
|
|
250
|
+
) -> bool:
|
|
251
|
+
if not index.isValid():
|
|
252
|
+
return False
|
|
253
|
+
if role == Qt.ItemDataRole.CheckStateRole:
|
|
254
|
+
item = index.internalPointer()
|
|
255
|
+
if index.column() == 0:
|
|
256
|
+
if isinstance(item, (Slider, Combo, Traversal)):
|
|
257
|
+
item.enabled = value == Qt.CheckState.Checked.value
|
|
258
|
+
return True
|
|
259
|
+
elif role == Qt.ItemDataRole.EditRole:
|
|
260
|
+
item = index.internalPointer()
|
|
261
|
+
if index.column() == 0:
|
|
262
|
+
if isinstance(item, (Group, Slider, Combo, Traversal, ProgPair)):
|
|
263
|
+
item.name = value
|
|
264
|
+
return True
|
|
265
|
+
|
|
266
|
+
elif index.column() == 1:
|
|
267
|
+
if isinstance(item, Slider):
|
|
268
|
+
item.value = value
|
|
269
|
+
elif isinstance(item, ComboPair):
|
|
270
|
+
item.value = value
|
|
271
|
+
elif isinstance(item, TravPair):
|
|
272
|
+
item.value = value
|
|
273
|
+
|
|
274
|
+
elif index.column() == 2:
|
|
275
|
+
if isinstance(item, ProgPair):
|
|
276
|
+
item.value = value
|
|
277
|
+
return False
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
# VIEW MODELS
|
|
281
|
+
class BaseProxyModel(QSortFilterProxyModel):
|
|
282
|
+
"""Holds the common item/index translation code for my filter models
|
|
283
|
+
Again, This is just a concrete implementation of a Qt base class, so
|
|
284
|
+
documentation will be lacking
|
|
285
|
+
"""
|
|
286
|
+
|
|
287
|
+
def __init__(self, model: SimplexModel, parent: QWidget | None = None) -> None:
|
|
288
|
+
super().__init__(parent)
|
|
289
|
+
self.setSourceModel(model)
|
|
290
|
+
|
|
291
|
+
def sourceModel(self) -> SimplexModel:
|
|
292
|
+
return cast(SimplexModel, super().sourceModel())
|
|
293
|
+
|
|
294
|
+
def indexFromItem(self, item: TreeItem, column: int = 0) -> QModelIndex:
|
|
295
|
+
sourceModel = self.sourceModel()
|
|
296
|
+
sourceIndex = sourceModel.indexFromItem(item, column)
|
|
297
|
+
return self.mapFromSource(sourceIndex)
|
|
298
|
+
|
|
299
|
+
def itemFromIndex(self, index: QModelIndex) -> TreeItem | None:
|
|
300
|
+
sourceModel = self.sourceModel()
|
|
301
|
+
sIndex = self.mapToSource(index)
|
|
302
|
+
return sourceModel.itemFromIndex(sIndex)
|
|
303
|
+
|
|
304
|
+
def invalidate(self) -> None:
|
|
305
|
+
source = self.sourceModel()
|
|
306
|
+
if isinstance(source, QSortFilterProxyModel):
|
|
307
|
+
source.invalidate()
|
|
308
|
+
super().invalidate()
|
|
309
|
+
|
|
310
|
+
def invalidateFilter(self) -> None:
|
|
311
|
+
source = self.sourceModel()
|
|
312
|
+
if isinstance(source, QSortFilterProxyModel):
|
|
313
|
+
source.invalidateFilter()
|
|
314
|
+
super().invalidateFilter()
|
|
315
|
+
|
|
316
|
+
def filterAcceptsRow(self, sourceRow: int, sourceParent: QModelIndex) -> bool:
|
|
317
|
+
return True
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
class SliderModel(BaseProxyModel):
|
|
321
|
+
def filterAcceptsRow(self, sourceRow: int, sourceParent: QModelIndex) -> bool:
|
|
322
|
+
sourceIndex = self.sourceModel().index(sourceRow, 0, sourceParent)
|
|
323
|
+
if sourceIndex.isValid():
|
|
324
|
+
item = self.sourceModel().itemFromIndex(sourceIndex)
|
|
325
|
+
if isinstance(item, Group):
|
|
326
|
+
if item.groupType is not Slider:
|
|
327
|
+
return False
|
|
328
|
+
return super().filterAcceptsRow(sourceRow, sourceParent)
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
class ComboModel(BaseProxyModel):
|
|
332
|
+
def filterAcceptsRow(self, sourceRow: int, sourceParent: QModelIndex) -> bool:
|
|
333
|
+
sourceIndex = self.sourceModel().index(sourceRow, 0, sourceParent)
|
|
334
|
+
if sourceIndex.isValid():
|
|
335
|
+
item = self.sourceModel().itemFromIndex(sourceIndex)
|
|
336
|
+
if isinstance(item, Group):
|
|
337
|
+
if item.groupType is not Combo:
|
|
338
|
+
return False
|
|
339
|
+
return super().filterAcceptsRow(sourceRow, sourceParent)
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
class TraversalModel(BaseProxyModel):
|
|
343
|
+
def filterAcceptsRow(self, sourceRow: int, sourceParent: QModelIndex) -> bool:
|
|
344
|
+
sourceIndex = self.sourceModel().index(sourceRow, 0, sourceParent)
|
|
345
|
+
if sourceIndex.isValid():
|
|
346
|
+
item = self.sourceModel().itemFromIndex(sourceIndex)
|
|
347
|
+
if isinstance(item, Group):
|
|
348
|
+
if item.groupType is not Traversal:
|
|
349
|
+
return False
|
|
350
|
+
return super().filterAcceptsRow(sourceRow, sourceParent)
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
# FILTER MODELS
|
|
354
|
+
class SimplexFilterModel(BaseProxyModel):
|
|
355
|
+
"""Filter a model based off of a given string
|
|
356
|
+
Set the `filterString` object property to filter the model
|
|
357
|
+
"""
|
|
358
|
+
|
|
359
|
+
def __init__(self, model: SimplexModel, parent: QWidget | None = None) -> None:
|
|
360
|
+
super().__init__(model, parent)
|
|
361
|
+
self.setSourceModel(model)
|
|
362
|
+
self.filterShapes: bool = True
|
|
363
|
+
self._filterString: list[str] = []
|
|
364
|
+
self._filterReg: list[re.Pattern[str]] = []
|
|
365
|
+
self.isolateList: list[str] = []
|
|
366
|
+
|
|
367
|
+
@property
|
|
368
|
+
def filterString(self) -> str:
|
|
369
|
+
return " ".join(self._filterString)
|
|
370
|
+
|
|
371
|
+
@filterString.setter
|
|
372
|
+
def filterString(self, val: str) -> None:
|
|
373
|
+
self._filterString = val.split()
|
|
374
|
+
|
|
375
|
+
self._filterReg = []
|
|
376
|
+
for sp in self._filterString:
|
|
377
|
+
if sp[0] == "*":
|
|
378
|
+
rex = re.compile(sp, flags=re.I)
|
|
379
|
+
self._filterReg.append(rex)
|
|
380
|
+
else:
|
|
381
|
+
rex = re.compile(".*?".join(sp), flags=re.I)
|
|
382
|
+
self._filterReg.append(rex)
|
|
383
|
+
|
|
384
|
+
def filterAcceptsRow(self, sourceRow: int, sourceParent: QModelIndex) -> bool:
|
|
385
|
+
column = 0 # always sort by the first column #column = self.filterKeyColumn()
|
|
386
|
+
sourceIndex = self.sourceModel().index(sourceRow, column, sourceParent)
|
|
387
|
+
if sourceIndex.isValid():
|
|
388
|
+
if self.filterString or self.isolateList:
|
|
389
|
+
sourceItem = self.sourceModel().itemFromIndex(sourceIndex)
|
|
390
|
+
if isinstance(
|
|
391
|
+
sourceItem, (ProgPair, Slider, Combo, ComboPair, Progression)
|
|
392
|
+
):
|
|
393
|
+
if not self.checkChildren(sourceItem):
|
|
394
|
+
return False
|
|
395
|
+
|
|
396
|
+
return super().filterAcceptsRow(sourceRow, sourceParent)
|
|
397
|
+
|
|
398
|
+
def matchFilterString(self, itemString: str) -> bool:
|
|
399
|
+
if not self._filterString:
|
|
400
|
+
return True
|
|
401
|
+
for reg in self._filterReg:
|
|
402
|
+
if reg.search(itemString):
|
|
403
|
+
return True
|
|
404
|
+
return False
|
|
405
|
+
|
|
406
|
+
def matchIsolation(self, itemString: str) -> bool:
|
|
407
|
+
if self.isolateList:
|
|
408
|
+
return itemString in self.isolateList
|
|
409
|
+
return True
|
|
410
|
+
|
|
411
|
+
def checkChildren(self, sourceItem: TreeItem) -> bool:
|
|
412
|
+
if hasattr(sourceItem, 'name'):
|
|
413
|
+
itemString = sourceItem.name # type: ignore
|
|
414
|
+
if self.matchFilterString(itemString) and self.matchIsolation(itemString):
|
|
415
|
+
return True
|
|
416
|
+
|
|
417
|
+
sourceModel = self.sourceModel().sourceModel()
|
|
418
|
+
for row in range(sourceModel.getItemRowCount(sourceItem)):
|
|
419
|
+
childItem = sourceModel.getChildItem(sourceItem, row)
|
|
420
|
+
if childItem is not None:
|
|
421
|
+
return self.checkChildren(childItem)
|
|
422
|
+
|
|
423
|
+
return False
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
class SliderFilterModel(SimplexFilterModel):
|
|
427
|
+
"""Hide single shapes under a slider"""
|
|
428
|
+
|
|
429
|
+
def __init__(self, model: SimplexModel, parent: QWidget | None = None) -> None:
|
|
430
|
+
super().__init__(model, parent)
|
|
431
|
+
self.requires: list[Combo] = []
|
|
432
|
+
self.filterRequiresAny: bool = False
|
|
433
|
+
self.filterRequiresAll: bool = False
|
|
434
|
+
self.doFilter: bool = True
|
|
435
|
+
|
|
436
|
+
def filterAcceptsRow(self, sourceRow: int, sourceParent: QModelIndex) -> bool:
|
|
437
|
+
# always sort by the first column #column = self.filterKeyColumn()
|
|
438
|
+
column = 0
|
|
439
|
+
sourceIndex = self.sourceModel().index(sourceRow, column, sourceParent)
|
|
440
|
+
if sourceIndex.isValid():
|
|
441
|
+
data = self.sourceModel().itemFromIndex(sourceIndex)
|
|
442
|
+
if self.doFilter:
|
|
443
|
+
if isinstance(data, ProgPair):
|
|
444
|
+
if data.prog is None:
|
|
445
|
+
return False
|
|
446
|
+
elif len(data.prog.pairs) <= 2:
|
|
447
|
+
return False
|
|
448
|
+
elif data.shape.isRest:
|
|
449
|
+
return False
|
|
450
|
+
|
|
451
|
+
if (self.filterRequiresAny or self.filterRequiresAll) and self.requires:
|
|
452
|
+
# Ignore items that aren't part of the required combos, if requested
|
|
453
|
+
if isinstance(data, Slider):
|
|
454
|
+
sliGroups = [[i.slider for i in c.pairs] for c in self.requires]
|
|
455
|
+
if self.filterRequiresAny:
|
|
456
|
+
if not any(data in s for s in sliGroups):
|
|
457
|
+
return False
|
|
458
|
+
elif self.filterRequiresAll:
|
|
459
|
+
if not all(data in s for s in sliGroups):
|
|
460
|
+
return False
|
|
461
|
+
|
|
462
|
+
return super().filterAcceptsRow(sourceRow, sourceParent)
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
class ComboFilterModel(SimplexFilterModel):
|
|
466
|
+
"""Filter by slider when Show Dependent Combos is checked"""
|
|
467
|
+
|
|
468
|
+
def __init__(self, model: SimplexModel, parent: QWidget | None = None) -> None:
|
|
469
|
+
super().__init__(model, parent)
|
|
470
|
+
self.requires: list[Slider] = []
|
|
471
|
+
self.filterRequiresAll: bool = False
|
|
472
|
+
self.filterRequiresAny: bool = False
|
|
473
|
+
self.filterRequiresOnly: bool = False
|
|
474
|
+
|
|
475
|
+
def filterAcceptsRow(self, sourceRow: int, sourceParent: QModelIndex) -> bool:
|
|
476
|
+
# always sort by the first column #column = self.filterKeyColumn()
|
|
477
|
+
column = 0
|
|
478
|
+
sourceIndex = self.sourceModel().index(sourceRow, column, sourceParent)
|
|
479
|
+
if sourceIndex.isValid():
|
|
480
|
+
data = self.sourceModel().itemFromIndex(sourceIndex)
|
|
481
|
+
if self.filterShapes:
|
|
482
|
+
# ignore the SHAPE par if there's nothing under there
|
|
483
|
+
if isinstance(data, Progression):
|
|
484
|
+
if len(data.pairs) <= 2:
|
|
485
|
+
return False
|
|
486
|
+
# Ignore shape things if requested
|
|
487
|
+
if isinstance(data, ProgPair):
|
|
488
|
+
if data.prog is None:
|
|
489
|
+
return False
|
|
490
|
+
elif len(data.prog.pairs) <= 2:
|
|
491
|
+
return False
|
|
492
|
+
elif data.shape.isRest:
|
|
493
|
+
return False
|
|
494
|
+
if (
|
|
495
|
+
self.filterRequiresAny
|
|
496
|
+
or self.filterRequiresAll
|
|
497
|
+
or self.filterRequiresOnly
|
|
498
|
+
) and self.requires:
|
|
499
|
+
# Ignore items that don't use the required sliders if requested
|
|
500
|
+
if isinstance(data, Combo):
|
|
501
|
+
sliders = [i.slider for i in data.pairs]
|
|
502
|
+
if self.filterRequiresAll:
|
|
503
|
+
if not all(r in sliders for r in self.requires):
|
|
504
|
+
return False
|
|
505
|
+
elif self.filterRequiresAny:
|
|
506
|
+
if not any(r in sliders for r in self.requires):
|
|
507
|
+
return False
|
|
508
|
+
elif self.filterRequiresOnly:
|
|
509
|
+
if not all(r in self.requires for r in sliders):
|
|
510
|
+
return False
|
|
511
|
+
|
|
512
|
+
return super().filterAcceptsRow(sourceRow, sourceParent)
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
class TraversalFilterModel(SimplexFilterModel):
|
|
516
|
+
"""Hide single shapes under a slider"""
|
|
517
|
+
|
|
518
|
+
def __init__(self, model: SimplexModel, parent: QWidget | None = None) -> None:
|
|
519
|
+
super().__init__(model, parent)
|
|
520
|
+
self.doFilter = True
|
|
521
|
+
|
|
522
|
+
def filterAcceptsRow(self, sourceRow: int, sourceParent: QModelIndex) -> bool:
|
|
523
|
+
column = 0 # always sort by the first column #column = self.filterKeyColumn()
|
|
524
|
+
sourceIndex = self.sourceModel().index(sourceRow, column, sourceParent)
|
|
525
|
+
if sourceIndex.isValid():
|
|
526
|
+
if self.doFilter:
|
|
527
|
+
data = self.sourceModel().itemFromIndex(sourceIndex)
|
|
528
|
+
if isinstance(data, ProgPair):
|
|
529
|
+
if data.prog is None:
|
|
530
|
+
return False
|
|
531
|
+
elif len(data.prog.pairs) <= 2:
|
|
532
|
+
return False
|
|
533
|
+
elif data.shape.isRest:
|
|
534
|
+
return False
|
|
535
|
+
|
|
536
|
+
return super().filterAcceptsRow(sourceRow, sourceParent)
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
class FalloffDataModel(AdapterModel):
|
|
540
|
+
"""A model for displaying the data of Falloff objects"""
|
|
541
|
+
|
|
542
|
+
def __init__(self, simplex: Simplex, parent: QWidget | None) -> None:
|
|
543
|
+
super().__init__(simplex, parent)
|
|
544
|
+
self.simplex = simplex
|
|
545
|
+
|
|
546
|
+
def getItemAppendRow(self, item: TreeItem) -> int:
|
|
547
|
+
try:
|
|
548
|
+
return len(self.simplex.falloffs)
|
|
549
|
+
except AttributeError:
|
|
550
|
+
return 0
|
|
551
|
+
|
|
552
|
+
def index(
|
|
553
|
+
self, row: int, column: int = 0, parIndex: QModelIndex | None = None
|
|
554
|
+
) -> QModelIndex:
|
|
555
|
+
parIndex = QModelIndex() if parIndex is None else parIndex
|
|
556
|
+
if row < 0:
|
|
557
|
+
return QModelIndex()
|
|
558
|
+
try:
|
|
559
|
+
falloff = self.simplex.falloffs[row]
|
|
560
|
+
except IndexError:
|
|
561
|
+
return QModelIndex()
|
|
562
|
+
except AttributeError:
|
|
563
|
+
return QModelIndex()
|
|
564
|
+
return self.createIndex(row, column, falloff)
|
|
565
|
+
|
|
566
|
+
def parent(self, index: QModelIndex) -> QModelIndex:
|
|
567
|
+
return QModelIndex()
|
|
568
|
+
|
|
569
|
+
def rowCount(self, parent) -> int:
|
|
570
|
+
try:
|
|
571
|
+
return len(self.simplex.falloffs)
|
|
572
|
+
except AttributeError:
|
|
573
|
+
return 0
|
|
574
|
+
|
|
575
|
+
def columnCount(self, parent: QModelIndex) -> int:
|
|
576
|
+
return 8
|
|
577
|
+
|
|
578
|
+
def data(self, index: QModelIndex, role: int) -> Any:
|
|
579
|
+
if not index.isValid():
|
|
580
|
+
return None
|
|
581
|
+
falloff = index.internalPointer()
|
|
582
|
+
if not falloff:
|
|
583
|
+
return None
|
|
584
|
+
|
|
585
|
+
if role in (Qt.ItemDataRole.DisplayRole, Qt.ItemDataRole.EditRole):
|
|
586
|
+
if index.column() == 0:
|
|
587
|
+
return falloff.name
|
|
588
|
+
elif index.column() == 1:
|
|
589
|
+
st = falloff.splitType
|
|
590
|
+
sti = ("planar", "map").index(st.lower())
|
|
591
|
+
return sti
|
|
592
|
+
elif index.column() == 2:
|
|
593
|
+
ax = falloff.axis
|
|
594
|
+
axi = "xyz".index(ax.lower())
|
|
595
|
+
return axi
|
|
596
|
+
elif index.column() == 3:
|
|
597
|
+
return falloff.maxVal
|
|
598
|
+
elif index.column() == 4:
|
|
599
|
+
return falloff.maxHandle
|
|
600
|
+
elif index.column() == 5:
|
|
601
|
+
return falloff.minHandle
|
|
602
|
+
elif index.column() == 6:
|
|
603
|
+
return falloff.minVal
|
|
604
|
+
elif index.column() == 7:
|
|
605
|
+
return falloff.mapName
|
|
606
|
+
return None
|
|
607
|
+
|
|
608
|
+
def setData(self, index: QModelIndex, value: Any, role: int) -> bool:
|
|
609
|
+
if not index.isValid():
|
|
610
|
+
return False
|
|
611
|
+
falloff = index.internalPointer()
|
|
612
|
+
if not falloff:
|
|
613
|
+
return False
|
|
614
|
+
if role == Qt.ItemDataRole.EditRole:
|
|
615
|
+
if index.column() == 0:
|
|
616
|
+
falloff.name = value
|
|
617
|
+
elif index.column() == 1:
|
|
618
|
+
if value in [0, 1]:
|
|
619
|
+
value = ("planar", "map")[value]
|
|
620
|
+
falloff.splitType = value
|
|
621
|
+
elif index.column() == 2:
|
|
622
|
+
if value in [0, 1, 2]:
|
|
623
|
+
value = "XYZ"[value]
|
|
624
|
+
falloff.axis = value
|
|
625
|
+
elif index.column() == 3:
|
|
626
|
+
falloff.maxVal = value
|
|
627
|
+
elif index.column() == 4:
|
|
628
|
+
falloff.maxHandle = value
|
|
629
|
+
elif index.column() == 5:
|
|
630
|
+
falloff.minHandle = value
|
|
631
|
+
elif index.column() == 6:
|
|
632
|
+
falloff.minVal = value
|
|
633
|
+
elif index.column() == 7:
|
|
634
|
+
falloff.mapName = value
|
|
635
|
+
return True
|
|
636
|
+
return False
|
|
637
|
+
|
|
638
|
+
def flags(self, index: QModelIndex) -> Qt.ItemFlag:
|
|
639
|
+
return (
|
|
640
|
+
Qt.ItemFlag.ItemIsEnabled
|
|
641
|
+
| Qt.ItemFlag.ItemIsEditable
|
|
642
|
+
| Qt.ItemFlag.ItemIsSelectable
|
|
643
|
+
)
|
|
644
|
+
|
|
645
|
+
def itemFromIndex(self, index: QModelIndex) -> TreeItem:
|
|
646
|
+
return index.internalPointer()
|
|
647
|
+
|
|
648
|
+
def getItemRow(self, item: Falloff) -> int | None:
|
|
649
|
+
try:
|
|
650
|
+
idx = self.simplex.falloffs.index(item)
|
|
651
|
+
except ValueError:
|
|
652
|
+
return None
|
|
653
|
+
except AttributeError:
|
|
654
|
+
return None
|
|
655
|
+
return idx
|