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
simplexui/items/combo.py
ADDED
|
@@ -0,0 +1,645 @@
|
|
|
1
|
+
# Copyright 2016, Blur Studio
|
|
2
|
+
#
|
|
3
|
+
# This file is part of Simplex.
|
|
4
|
+
#
|
|
5
|
+
# Simplex is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# Simplex is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU Lesser General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
16
|
+
# along with Simplex. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
from typing import TYPE_CHECKING, Any
|
|
20
|
+
|
|
21
|
+
from .accessor import SimplexTreeAccessor
|
|
22
|
+
from .dragItem import Draggable
|
|
23
|
+
from .stack import stackable
|
|
24
|
+
from .treeItem import TreeItem
|
|
25
|
+
|
|
26
|
+
if TYPE_CHECKING:
|
|
27
|
+
from .group import Group
|
|
28
|
+
from .progression import Progression, ProgPair
|
|
29
|
+
from .shape import Shape
|
|
30
|
+
from .simplex import Simplex
|
|
31
|
+
from .slider import Slider
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# Abstract Items
|
|
35
|
+
class ComboPair(SimplexTreeAccessor, Draggable):
|
|
36
|
+
"""A Slider/Value pair for use in Combos"""
|
|
37
|
+
|
|
38
|
+
classDepth: int = 6
|
|
39
|
+
|
|
40
|
+
def __init__(self, slider: Slider, value: float) -> None:
|
|
41
|
+
super().__init__(slider.simplex)
|
|
42
|
+
self.slider: Slider = slider
|
|
43
|
+
self._value: float = float(value)
|
|
44
|
+
self.combo: Combo | None = None
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
def name(self) -> str:
|
|
48
|
+
return self.slider.name
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def value(self) -> float:
|
|
52
|
+
return self._value
|
|
53
|
+
|
|
54
|
+
@value.setter
|
|
55
|
+
@stackable
|
|
56
|
+
def value(self, val: float) -> None:
|
|
57
|
+
self._value = val
|
|
58
|
+
|
|
59
|
+
def buildDefinition(self, simpDict: dict, legacy: bool) -> tuple[int, float]:
|
|
60
|
+
sIdx = self.slider.buildDefinition(simpDict, legacy)
|
|
61
|
+
return sIdx, self.value
|
|
62
|
+
|
|
63
|
+
def treeRow(self) -> int:
|
|
64
|
+
if self.combo is None:
|
|
65
|
+
return 0
|
|
66
|
+
return self.combo.pairs.index(self)
|
|
67
|
+
|
|
68
|
+
def treeParent(self) -> TreeItem | None:
|
|
69
|
+
return self.combo
|
|
70
|
+
|
|
71
|
+
def treeData(self, column: int) -> Any | None:
|
|
72
|
+
if column == 0:
|
|
73
|
+
return self.name
|
|
74
|
+
if column == 1:
|
|
75
|
+
return self.value
|
|
76
|
+
return None
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class Combo(SimplexTreeAccessor):
|
|
80
|
+
"""A group of Slider/Value pairs that control a Progression through some solver
|
|
81
|
+
|
|
82
|
+
Combos allow for fixit shapes to be created for any number of user inputs.
|
|
83
|
+
They also allow for fixits along the progression, and in "floating space" where
|
|
84
|
+
the inputs are not -1 or 1
|
|
85
|
+
|
|
86
|
+
Parameters
|
|
87
|
+
----------
|
|
88
|
+
name : str
|
|
89
|
+
The name of this Combo
|
|
90
|
+
simplex : Simplex
|
|
91
|
+
The parent Simplex system
|
|
92
|
+
pairs : [ComboPair
|
|
93
|
+
The Slider/Value pairs that make up this combo
|
|
94
|
+
prog : Progression
|
|
95
|
+
The Progression that this Combo controls
|
|
96
|
+
group : Group
|
|
97
|
+
The Group to create this combo in
|
|
98
|
+
solveType : str
|
|
99
|
+
The solve type for this combo. See Combo.solveTypes for a list
|
|
100
|
+
color : QColor
|
|
101
|
+
The color of this item in the UI
|
|
102
|
+
"""
|
|
103
|
+
|
|
104
|
+
classDepth = 5
|
|
105
|
+
solveTypes = (
|
|
106
|
+
("Minimum", "min"),
|
|
107
|
+
("Multiply All", "allMul"),
|
|
108
|
+
("Multiply Extremes", "extMul"),
|
|
109
|
+
("Multiply Avg of Extremes", "mulAvgExt"),
|
|
110
|
+
("Multiply Avg", "mulAvgAll"),
|
|
111
|
+
("None", "min"),
|
|
112
|
+
)
|
|
113
|
+
_freezeIcon = None
|
|
114
|
+
|
|
115
|
+
def __init__(
|
|
116
|
+
self,
|
|
117
|
+
name: str,
|
|
118
|
+
simplex: Simplex,
|
|
119
|
+
pairs: list[ComboPair],
|
|
120
|
+
prog: Progression,
|
|
121
|
+
group: Group,
|
|
122
|
+
solveType: str | None,
|
|
123
|
+
) -> None:
|
|
124
|
+
super().__init__(simplex)
|
|
125
|
+
|
|
126
|
+
if group.groupType is not type(self):
|
|
127
|
+
raise ValueError("Cannot add this slider to a combo group")
|
|
128
|
+
with self.stack.store(self):
|
|
129
|
+
self._name: str = name
|
|
130
|
+
self.pairs = pairs
|
|
131
|
+
self.prog = prog
|
|
132
|
+
self.prog.controller = self
|
|
133
|
+
self._solveType: str | None = solveType
|
|
134
|
+
self._buildIdx = None
|
|
135
|
+
self.expanded = {}
|
|
136
|
+
self._enabled = True
|
|
137
|
+
self._freezeThing = None
|
|
138
|
+
for p in self.pairs:
|
|
139
|
+
p.combo = self
|
|
140
|
+
self.simplex.combos.append(self)
|
|
141
|
+
|
|
142
|
+
with self.insertItemManager(group):
|
|
143
|
+
self.group: Group = group
|
|
144
|
+
self.group.items.append(self)
|
|
145
|
+
|
|
146
|
+
@property
|
|
147
|
+
def enabled(self) -> bool:
|
|
148
|
+
"""Get whether this Combo is evaluated in the solver"""
|
|
149
|
+
return self._enabled
|
|
150
|
+
|
|
151
|
+
@enabled.setter
|
|
152
|
+
@stackable
|
|
153
|
+
def enabled(self, value: bool) -> None:
|
|
154
|
+
"""Set whether this Combo is evaluated in the solver"""
|
|
155
|
+
self._enabled = value
|
|
156
|
+
|
|
157
|
+
@property
|
|
158
|
+
def frozen(self) -> bool:
|
|
159
|
+
"""Get whether this Combo is frozen"""
|
|
160
|
+
return bool(self.freezeThing)
|
|
161
|
+
|
|
162
|
+
@property
|
|
163
|
+
def freezeThing(self) -> Any:
|
|
164
|
+
"""Get whether this Combo is frozen"""
|
|
165
|
+
if self._freezeThing is None:
|
|
166
|
+
self._freezeThing = self.DCC.getFreezeThing(self)
|
|
167
|
+
return self._freezeThing
|
|
168
|
+
|
|
169
|
+
@freezeThing.setter
|
|
170
|
+
def freezeThing(self, value: Any) -> None:
|
|
171
|
+
self._freezeThing = value
|
|
172
|
+
|
|
173
|
+
@classmethod
|
|
174
|
+
def comboAlreadyExists(
|
|
175
|
+
cls, simplex: Simplex, sliders: list[Slider], values: list[float]
|
|
176
|
+
) -> Combo | None:
|
|
177
|
+
"""Classmethod to check whether a combo already exists with these sliders and values
|
|
178
|
+
|
|
179
|
+
Parameters
|
|
180
|
+
----------
|
|
181
|
+
simplex : Simplex
|
|
182
|
+
The system to check within
|
|
183
|
+
sliders : [Slider
|
|
184
|
+
The Sliders to check
|
|
185
|
+
values : [float
|
|
186
|
+
The values to zip with the sliders
|
|
187
|
+
|
|
188
|
+
Returns
|
|
189
|
+
-------
|
|
190
|
+
: Combo or None
|
|
191
|
+
The combo that exists with the given values, or None if none exist
|
|
192
|
+
"""
|
|
193
|
+
checker = {(s.name, v) for s, v in zip(sliders, values)}
|
|
194
|
+
for combo in simplex.combos:
|
|
195
|
+
tester = {(p.slider.name, p.value) for p in combo.pairs}
|
|
196
|
+
if checker == tester:
|
|
197
|
+
return combo
|
|
198
|
+
return None
|
|
199
|
+
|
|
200
|
+
@classmethod
|
|
201
|
+
def createCombo(
|
|
202
|
+
cls,
|
|
203
|
+
name: str,
|
|
204
|
+
simplex: Simplex,
|
|
205
|
+
sliders: list[Slider],
|
|
206
|
+
values: list[float],
|
|
207
|
+
group: Group | None = None,
|
|
208
|
+
shape: Shape | None = None,
|
|
209
|
+
solveType: str | None = None,
|
|
210
|
+
tVal: float = 1.0,
|
|
211
|
+
) -> Combo:
|
|
212
|
+
"""Classmethod to create Combo with some hard-coded defaults
|
|
213
|
+
|
|
214
|
+
Parameters
|
|
215
|
+
----------
|
|
216
|
+
name : str
|
|
217
|
+
The name of the Combo
|
|
218
|
+
simplex : Simplex
|
|
219
|
+
The Simplex system
|
|
220
|
+
sliders : [Slider
|
|
221
|
+
The Sliders that will control this combo
|
|
222
|
+
values : [float
|
|
223
|
+
The values at which the sliders will activate this combo
|
|
224
|
+
group : Group or None
|
|
225
|
+
A Group to organize this combo.
|
|
226
|
+
If None, the combo will be sorted into a "DEPTH" group (Default value = None)
|
|
227
|
+
shape : Shape or None
|
|
228
|
+
A Shape for this Combo's Progression. If None, then a default shape will be created
|
|
229
|
+
solveType : str or None
|
|
230
|
+
The solve type for this Combo. if None, defaults to 'min' in the solver
|
|
231
|
+
tVal : float
|
|
232
|
+
The slideValue where the Shape will be created/added. Defaults to 1.0
|
|
233
|
+
|
|
234
|
+
Returns
|
|
235
|
+
-------
|
|
236
|
+
: Combo
|
|
237
|
+
The newly created Combo
|
|
238
|
+
"""
|
|
239
|
+
if simplex.restShape is None:
|
|
240
|
+
raise RuntimeError("Simplex system is missing rest shape")
|
|
241
|
+
|
|
242
|
+
# Make sure to check if this combo already exists. If so, just return it
|
|
243
|
+
exist = cls.comboAlreadyExists(simplex, sliders, values)
|
|
244
|
+
if exist is not None:
|
|
245
|
+
return exist
|
|
246
|
+
from .group import Group
|
|
247
|
+
from .progression import ProgPair, Progression
|
|
248
|
+
|
|
249
|
+
if group is None:
|
|
250
|
+
gname = f"DEPTH_{len(sliders)}"
|
|
251
|
+
matches = [i for i in simplex.comboGroups if i.name == gname]
|
|
252
|
+
if matches:
|
|
253
|
+
group = matches[0]
|
|
254
|
+
else:
|
|
255
|
+
group = Group(gname, simplex, Combo)
|
|
256
|
+
|
|
257
|
+
cPairs = [ComboPair(slider, value) for slider, value in zip(sliders, values)]
|
|
258
|
+
prog = Progression(name, simplex)
|
|
259
|
+
if shape:
|
|
260
|
+
prog.pairs.append(ProgPair(simplex, shape, tVal))
|
|
261
|
+
|
|
262
|
+
cmb = Combo(name, simplex, cPairs, prog, group, solveType)
|
|
263
|
+
|
|
264
|
+
if shape is None:
|
|
265
|
+
pp = prog.createShape(name, tVal)
|
|
266
|
+
simplex.DCC.zeroShape(pp.shape)
|
|
267
|
+
|
|
268
|
+
return cmb
|
|
269
|
+
|
|
270
|
+
@staticmethod
|
|
271
|
+
def buildComboName(sliders, values):
|
|
272
|
+
"""Build the name for a combo based on the input Sliders and values
|
|
273
|
+
The sliders will be alphabetically sorted
|
|
274
|
+
Values not at Shape increments within the progression will get numeric
|
|
275
|
+
suffixes. Negative values will have suffixes like "n75"
|
|
276
|
+
|
|
277
|
+
Parameters
|
|
278
|
+
----------
|
|
279
|
+
sliders : [Slider
|
|
280
|
+
The sliders to check
|
|
281
|
+
values : [float
|
|
282
|
+
The values for the sliders
|
|
283
|
+
|
|
284
|
+
Returns
|
|
285
|
+
-------
|
|
286
|
+
: str
|
|
287
|
+
The suggested combo name
|
|
288
|
+
"""
|
|
289
|
+
pairs = list(zip(sliders, values))
|
|
290
|
+
pairs = sorted(pairs, key=lambda x: x[0].name)
|
|
291
|
+
parts = []
|
|
292
|
+
for slider, value in pairs:
|
|
293
|
+
shape = slider.prog.getShapeAtValue(value)
|
|
294
|
+
if shape is not None:
|
|
295
|
+
parts.append(shape.name)
|
|
296
|
+
else:
|
|
297
|
+
# get the extreme shape and percentage-ize its name
|
|
298
|
+
extVal = 1.0 if value > 0.0 else -1.0
|
|
299
|
+
|
|
300
|
+
valName = f"{abs(int(value * 100))}"
|
|
301
|
+
valName = "n" + valName if value < 0.0 else valName
|
|
302
|
+
|
|
303
|
+
shape = slider.prog.getShapeAtValue(extVal)
|
|
304
|
+
if shape is not None:
|
|
305
|
+
sn = shape.name
|
|
306
|
+
sn = sn.split("_")
|
|
307
|
+
if sn[-1].isnumeric() or (
|
|
308
|
+
sn[-1][0] == "n" and sn[-1][1:].isnumeric()
|
|
309
|
+
):
|
|
310
|
+
sn[-1] = valName
|
|
311
|
+
else:
|
|
312
|
+
sn.append(valName)
|
|
313
|
+
nsn = "_".join(sn)
|
|
314
|
+
parts.append(nsn)
|
|
315
|
+
else:
|
|
316
|
+
parts.append(slider.name)
|
|
317
|
+
|
|
318
|
+
return "_".join(parts)
|
|
319
|
+
|
|
320
|
+
@property
|
|
321
|
+
def name(self) -> str:
|
|
322
|
+
"""Get the name of a combo"""
|
|
323
|
+
return self._name
|
|
324
|
+
|
|
325
|
+
@name.setter
|
|
326
|
+
@stackable
|
|
327
|
+
def name(self, value) -> None:
|
|
328
|
+
"""Set the name of a combo"""
|
|
329
|
+
self._name = value
|
|
330
|
+
self.prog.name = value
|
|
331
|
+
self.DCC.renameCombo(self, value)
|
|
332
|
+
|
|
333
|
+
@property
|
|
334
|
+
def solveType(self) -> str | None:
|
|
335
|
+
"""Get the solveType of the combo"""
|
|
336
|
+
return self._solveType
|
|
337
|
+
|
|
338
|
+
@solveType.setter
|
|
339
|
+
@stackable
|
|
340
|
+
def solveType(self, newType: str) -> None:
|
|
341
|
+
"""Set the solveType of the combo"""
|
|
342
|
+
stNames, stVals = list(zip(*self.solveTypes))
|
|
343
|
+
if newType not in stVals:
|
|
344
|
+
raise ValueError(f"Solve Type {newType} not in allowed types {stVals}")
|
|
345
|
+
self._solveType = newType
|
|
346
|
+
|
|
347
|
+
def sliderNameLinks(self) -> list[bool]:
|
|
348
|
+
""" """
|
|
349
|
+
sliNames = [f"_{i.slider.name}_" for i in self.pairs]
|
|
350
|
+
surr = f"_{self.name}_"
|
|
351
|
+
return [sn in surr for sn in sliNames]
|
|
352
|
+
|
|
353
|
+
def nameLinks(self):
|
|
354
|
+
"""
|
|
355
|
+
|
|
356
|
+
Parameters
|
|
357
|
+
----------
|
|
358
|
+
|
|
359
|
+
Returns
|
|
360
|
+
-------
|
|
361
|
+
: type
|
|
362
|
+
progression depends on this slider's name
|
|
363
|
+
"""
|
|
364
|
+
# In this case, these names will *NOT* have the possibility of
|
|
365
|
+
# a pos/neg name. Only the combo name, and possibly a percentage
|
|
366
|
+
shapeNames = []
|
|
367
|
+
shapes = [i.shape for i in self.prog.pairs]
|
|
368
|
+
for s in shapes:
|
|
369
|
+
x = s.name.rsplit("_", 1)
|
|
370
|
+
if len(x) == 2:
|
|
371
|
+
base, sfx = x
|
|
372
|
+
x = base if sfx.isdigit() else s.name
|
|
373
|
+
shapeNames.append(x)
|
|
374
|
+
return [i == self.name for i in shapeNames]
|
|
375
|
+
|
|
376
|
+
def getSliderIndex(self, slider) -> int:
|
|
377
|
+
for i, p in enumerate(self.pairs):
|
|
378
|
+
if p.slider == slider:
|
|
379
|
+
return i
|
|
380
|
+
raise ValueError(f"Provided slider:{slider.name} is not in the list")
|
|
381
|
+
|
|
382
|
+
def isFloating(self) -> bool:
|
|
383
|
+
"""Floating combos are combos that Slider values that are between 0 and 1"""
|
|
384
|
+
for pair in self.pairs:
|
|
385
|
+
if abs(pair.value) != 1.0:
|
|
386
|
+
return True
|
|
387
|
+
return False
|
|
388
|
+
|
|
389
|
+
def getSliders(self) -> list[Slider]:
|
|
390
|
+
""" """
|
|
391
|
+
return [i.slider for i in self.pairs]
|
|
392
|
+
|
|
393
|
+
@classmethod
|
|
394
|
+
def loadV2(cls, simplex, progs, data):
|
|
395
|
+
"""Load the data from a version2 formatted json dictionary
|
|
396
|
+
|
|
397
|
+
Parameters
|
|
398
|
+
----------
|
|
399
|
+
simplex : Simplex
|
|
400
|
+
The Simplex system that's being built
|
|
401
|
+
progs : [Progression
|
|
402
|
+
The progressions that have already been built
|
|
403
|
+
data : dict
|
|
404
|
+
The chunk of the json dict used to build this object
|
|
405
|
+
|
|
406
|
+
Returns
|
|
407
|
+
-------
|
|
408
|
+
: Combo
|
|
409
|
+
The specified combo
|
|
410
|
+
"""
|
|
411
|
+
name = data["name"]
|
|
412
|
+
prog = progs[data["prog"]]
|
|
413
|
+
group = simplex.groups[data.get("group", 1)]
|
|
414
|
+
pairs = [ComboPair(simplex.sliders[s], v) for s, v in data["pairs"]]
|
|
415
|
+
solveType = data.get("solveType")
|
|
416
|
+
return cls(name, simplex, pairs, prog, group, solveType)
|
|
417
|
+
|
|
418
|
+
def buildDefinition(self, simpDict, legacy):
|
|
419
|
+
"""Output a dictionary definition of this object
|
|
420
|
+
|
|
421
|
+
Parameters
|
|
422
|
+
----------
|
|
423
|
+
simpDict : dict
|
|
424
|
+
The dictionary that is being built
|
|
425
|
+
legacy : bool
|
|
426
|
+
Whether to write out the legacy definition, or the newer one
|
|
427
|
+
"""
|
|
428
|
+
if self._buildIdx is None:
|
|
429
|
+
self._buildIdx = len(simpDict["combos"])
|
|
430
|
+
if legacy:
|
|
431
|
+
gIdx = self.group.buildDefinition(simpDict, legacy)
|
|
432
|
+
pIdx = self.prog.buildDefinition(simpDict, legacy)
|
|
433
|
+
idxPairs = [p.buildDefinition(simpDict, legacy) for p in self.pairs]
|
|
434
|
+
x = [self.name, pIdx, idxPairs, gIdx]
|
|
435
|
+
simpDict.setdefault("combos", []).append(x)
|
|
436
|
+
else:
|
|
437
|
+
x = {
|
|
438
|
+
"name": self.name,
|
|
439
|
+
"prog": self.prog.buildDefinition(simpDict, legacy),
|
|
440
|
+
"pairs": [p.buildDefinition(simpDict, legacy) for p in self.pairs],
|
|
441
|
+
"group": self.group.buildDefinition(simpDict, legacy),
|
|
442
|
+
"enabled": self._enabled,
|
|
443
|
+
"solveType": str(self._solveType),
|
|
444
|
+
}
|
|
445
|
+
simpDict.setdefault("combos", []).append(x)
|
|
446
|
+
return self._buildIdx
|
|
447
|
+
|
|
448
|
+
def clearBuildIndex(self) -> None:
|
|
449
|
+
"""Clear the build index of this object
|
|
450
|
+
|
|
451
|
+
The buildIndex is stored when building a definition dictionary
|
|
452
|
+
that keeps track of its index for later referencing
|
|
453
|
+
"""
|
|
454
|
+
self._buildIdx = None
|
|
455
|
+
self.prog.clearBuildIndex()
|
|
456
|
+
self.group.clearBuildIndex()
|
|
457
|
+
|
|
458
|
+
def extractShape(self, shape, live: bool = True, offset: float = 10.0):
|
|
459
|
+
"""Extract a shape from a combo progression
|
|
460
|
+
|
|
461
|
+
Parameters
|
|
462
|
+
----------
|
|
463
|
+
shape : Shape
|
|
464
|
+
The Shape object to extract as a mesh
|
|
465
|
+
live : bool
|
|
466
|
+
Whether to maintain a live connection to the extracted mesh in the DCC (Default value = True)
|
|
467
|
+
offset : float
|
|
468
|
+
The offset to give the extracted mesh in the DCC (Default value = 10.0)
|
|
469
|
+
|
|
470
|
+
Returns
|
|
471
|
+
-------
|
|
472
|
+
: object
|
|
473
|
+
The DCC mesh just created
|
|
474
|
+
"""
|
|
475
|
+
return self.DCC.extractComboShape(self, shape, live, offset)
|
|
476
|
+
|
|
477
|
+
def connectShape(
|
|
478
|
+
self, shape, mesh=None, live: bool = False, delete: bool = False
|
|
479
|
+
) -> None:
|
|
480
|
+
"""Connect a shape into a combo progression
|
|
481
|
+
|
|
482
|
+
Parameters
|
|
483
|
+
----------
|
|
484
|
+
shape : Shape
|
|
485
|
+
The shape to connect the mesh to
|
|
486
|
+
mesh : object or None
|
|
487
|
+
A DCC mesh to connect into a Shape
|
|
488
|
+
If None, tries to connect by name (Default value = None)
|
|
489
|
+
live : bool
|
|
490
|
+
Whether to maintain a live connecto to the mesh in the DCC (Default value = False)
|
|
491
|
+
delete : bool
|
|
492
|
+
Whether to delete the DCC mesh after it was connected (Default value = False)
|
|
493
|
+
"""
|
|
494
|
+
self.DCC.connectComboShape(self, shape, mesh, live, delete)
|
|
495
|
+
|
|
496
|
+
@stackable
|
|
497
|
+
def delete(self) -> None:
|
|
498
|
+
"""Delete this combo and any shapes it contains"""
|
|
499
|
+
if self not in self.group.items:
|
|
500
|
+
return # Can happen when deleting multiple groups
|
|
501
|
+
|
|
502
|
+
with self.removeItemManager(self):
|
|
503
|
+
self.group.items.remove(self)
|
|
504
|
+
self.group = None # type: ignore # Just clearing out references
|
|
505
|
+
self.simplex.combos.remove(self)
|
|
506
|
+
pairs = self.prog.pairs[:] # gotta make a copy
|
|
507
|
+
for pp in pairs:
|
|
508
|
+
if not pp.shape.isRest:
|
|
509
|
+
self.simplex.shapes.remove(pp.shape)
|
|
510
|
+
self.DCC.deleteShape(pp.shape)
|
|
511
|
+
|
|
512
|
+
@stackable
|
|
513
|
+
def setInterpolation(self, interp) -> None:
|
|
514
|
+
"""Set the interpolation of a combo
|
|
515
|
+
|
|
516
|
+
Parameters
|
|
517
|
+
----------
|
|
518
|
+
interp : str
|
|
519
|
+
The interpolation for this combo's progression
|
|
520
|
+
"""
|
|
521
|
+
self.prog.interp = interp
|
|
522
|
+
|
|
523
|
+
@stackable
|
|
524
|
+
def setComboValue(self, slider, value) -> None:
|
|
525
|
+
"""Set the Slider/value pairs for a combo
|
|
526
|
+
|
|
527
|
+
Parameters
|
|
528
|
+
----------
|
|
529
|
+
slider : Slider
|
|
530
|
+
The slider to set the value for
|
|
531
|
+
value : float
|
|
532
|
+
The value to set the Slider to
|
|
533
|
+
"""
|
|
534
|
+
idx = self.getSliderIndex(slider)
|
|
535
|
+
pair = self.pairs[idx]
|
|
536
|
+
pair.value = value
|
|
537
|
+
|
|
538
|
+
@stackable
|
|
539
|
+
def appendComboValue(self, slider, value) -> None:
|
|
540
|
+
"""Append a Slider/value pair for a combo
|
|
541
|
+
|
|
542
|
+
Parameters
|
|
543
|
+
----------
|
|
544
|
+
slider : Slider
|
|
545
|
+
The slider to insert
|
|
546
|
+
value : float
|
|
547
|
+
The value to set the Slider to
|
|
548
|
+
"""
|
|
549
|
+
cp = ComboPair(slider, value)
|
|
550
|
+
with self.insertItemManager(self):
|
|
551
|
+
self.pairs.append(cp)
|
|
552
|
+
cp.combo = self
|
|
553
|
+
|
|
554
|
+
@stackable
|
|
555
|
+
def deleteComboPair(self, comboPair) -> None:
|
|
556
|
+
"""Delete a Slider/value pair for a combo
|
|
557
|
+
|
|
558
|
+
Parameters
|
|
559
|
+
----------
|
|
560
|
+
comboPair : ComboPair
|
|
561
|
+
The ComboPair to delete
|
|
562
|
+
"""
|
|
563
|
+
# We specifically don't move the combo to the proper depth group
|
|
564
|
+
# That way the user can make multiple changes to the combo without
|
|
565
|
+
# it popping all over in the heirarchy
|
|
566
|
+
with self.removeItemManager(comboPair):
|
|
567
|
+
self.pairs.remove(comboPair)
|
|
568
|
+
comboPair.combo = None
|
|
569
|
+
|
|
570
|
+
@stackable
|
|
571
|
+
def setGroup(self, grp) -> None:
|
|
572
|
+
"""Set the group for this Combo
|
|
573
|
+
|
|
574
|
+
Parameters
|
|
575
|
+
----------
|
|
576
|
+
grp : Group
|
|
577
|
+
The group to set
|
|
578
|
+
"""
|
|
579
|
+
if grp.groupType is None:
|
|
580
|
+
grp.groupType = type(self)
|
|
581
|
+
|
|
582
|
+
if not isinstance(self, grp.groupType):
|
|
583
|
+
raise ValueError(
|
|
584
|
+
f"All items in this group must be of type: {grp.groupType}"
|
|
585
|
+
)
|
|
586
|
+
|
|
587
|
+
with self.moveItemManager(self, grp):
|
|
588
|
+
if self.group:
|
|
589
|
+
self.group.items.remove(self)
|
|
590
|
+
grp.items.append(self)
|
|
591
|
+
self.group = grp
|
|
592
|
+
|
|
593
|
+
@stackable
|
|
594
|
+
def createShape(self, shapeName=None, tVal=None) -> ProgPair:
|
|
595
|
+
"""Create a shape and add it to a progression
|
|
596
|
+
|
|
597
|
+
Parameters
|
|
598
|
+
----------
|
|
599
|
+
shapeName : str or None
|
|
600
|
+
The name of the shape to create.
|
|
601
|
+
If None, give it a default name
|
|
602
|
+
tVal : float or None
|
|
603
|
+
The progression value to set for the new Shape.
|
|
604
|
+
If None, it gets a "smart" default value
|
|
605
|
+
"""
|
|
606
|
+
pp, idx = self.prog.newProgPair(shapeName, tVal)
|
|
607
|
+
with self.insertItemManager(self.prog, row=idx):
|
|
608
|
+
pp.prog = self.prog
|
|
609
|
+
self.prog.pairs.insert(idx, pp)
|
|
610
|
+
return pp
|
|
611
|
+
|
|
612
|
+
def getInputVector(self) -> list[float]:
|
|
613
|
+
"""Get the input to the Solver that would fully activate this Combo
|
|
614
|
+
|
|
615
|
+
Returns
|
|
616
|
+
-------
|
|
617
|
+
: [float, ...]
|
|
618
|
+
The ordered slider values
|
|
619
|
+
"""
|
|
620
|
+
inVec = [0.0] * len(self.simplex.sliders)
|
|
621
|
+
for cp in self.pairs:
|
|
622
|
+
inVec[self.simplex.sliders.index(cp.slider)] = cp.value
|
|
623
|
+
return inVec
|
|
624
|
+
|
|
625
|
+
def treeChild(self, row: int) -> TreeItem:
|
|
626
|
+
if row == len(self.pairs):
|
|
627
|
+
return self.prog
|
|
628
|
+
return self.pairs[row]
|
|
629
|
+
|
|
630
|
+
def treeRow(self) -> int:
|
|
631
|
+
return self.group.items.index(self)
|
|
632
|
+
|
|
633
|
+
def treeParent(self) -> TreeItem:
|
|
634
|
+
return self.group
|
|
635
|
+
|
|
636
|
+
def treeChildCount(self) -> int:
|
|
637
|
+
return len(self.pairs) + 1
|
|
638
|
+
|
|
639
|
+
def treeChecked(self) -> bool:
|
|
640
|
+
return self.enabled
|
|
641
|
+
|
|
642
|
+
def treeData(self, column: int) -> Any | None:
|
|
643
|
+
if column == 0:
|
|
644
|
+
return self.name
|
|
645
|
+
return None
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
|
|
21
|
+
class Draggable:
|
|
22
|
+
"""A mixin to make an item middle-click draggable"""
|
|
23
|
+
|
|
24
|
+
# This is in a separate file from the DragFilter so that no Qt imports
|
|
25
|
+
# are required for the core Simplex items
|
|
26
|
+
dragStep: float = 0.05
|
|
27
|
+
maxValue: float = 1.0
|
|
28
|
+
minValue: float = 0.0
|
|
29
|
+
|
|
30
|
+
def valueTick(self, ticks: int, mul: float) -> None:
|
|
31
|
+
"""Change the value of the current object by some number of ticks
|
|
32
|
+
with some given multiplier. This is the interface for the MMB drag
|
|
33
|
+
|
|
34
|
+
Parameters
|
|
35
|
+
----------
|
|
36
|
+
ticks : int
|
|
37
|
+
The number of dragStep ticks to apply
|
|
38
|
+
mul : float
|
|
39
|
+
An overall multiplier
|
|
40
|
+
"""
|
|
41
|
+
val = self.value + (self.dragStep * ticks * mul)
|
|
42
|
+
val = 0.0 if abs(val) < 1e-5 else val
|
|
43
|
+
val = max(min(val, self.maxValue), self.minValue)
|
|
44
|
+
self.value = val
|