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,632 @@
|
|
|
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
|
+
import itertools
|
|
20
|
+
from typing import TYPE_CHECKING, Any
|
|
21
|
+
|
|
22
|
+
from ..interface import undoContext
|
|
23
|
+
from ..utils import caseSplit, getNextName, makeUnique, singleShot
|
|
24
|
+
from .accessor import SimplexTreeAccessor
|
|
25
|
+
from .dragItem import Draggable
|
|
26
|
+
from .group import Group
|
|
27
|
+
from .progression import ProgPair, Progression
|
|
28
|
+
from .shape import Shape
|
|
29
|
+
from .stack import stackable
|
|
30
|
+
from .treeItem import TreeItem
|
|
31
|
+
|
|
32
|
+
if TYPE_CHECKING:
|
|
33
|
+
from .simplex import DCCObject, Simplex
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class Slider(SimplexTreeAccessor, Draggable):
|
|
37
|
+
"""A user-input to the simplex system that directly controls a Progression
|
|
38
|
+
|
|
39
|
+
Parameters
|
|
40
|
+
----------
|
|
41
|
+
name : str
|
|
42
|
+
The name of this Slider
|
|
43
|
+
simplex : Simplex
|
|
44
|
+
The parent Simplex system
|
|
45
|
+
prog : Progression
|
|
46
|
+
The Progression that this Slider controls
|
|
47
|
+
group : Group
|
|
48
|
+
The Group to create this Slider in
|
|
49
|
+
color : QColor
|
|
50
|
+
The color of this item in the UI
|
|
51
|
+
create : bool
|
|
52
|
+
Whether to create a DCC Shape, or look for it already in-scene
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
classDepth: int = 7
|
|
56
|
+
|
|
57
|
+
def __init__(
|
|
58
|
+
self,
|
|
59
|
+
name: str,
|
|
60
|
+
simplex: Simplex,
|
|
61
|
+
prog: Progression,
|
|
62
|
+
group: Group,
|
|
63
|
+
create: bool = True,
|
|
64
|
+
) -> None:
|
|
65
|
+
if group.groupType is not type(self):
|
|
66
|
+
raise ValueError("Cannot add this slider to a combo group")
|
|
67
|
+
|
|
68
|
+
super().__init__(simplex)
|
|
69
|
+
|
|
70
|
+
with self.stack.store(self):
|
|
71
|
+
self._name: str = name
|
|
72
|
+
self._thing: DCCObject | None = None
|
|
73
|
+
self._thingRepr: str | None = None
|
|
74
|
+
self.prog: Progression = prog
|
|
75
|
+
self.prog.controller = self
|
|
76
|
+
self.split: bool = False
|
|
77
|
+
self._buildIdx: int | None = None
|
|
78
|
+
self._value: float = 0.0
|
|
79
|
+
self._enabled: bool = True
|
|
80
|
+
|
|
81
|
+
mn, mx = self.prog.getRange()
|
|
82
|
+
self.minValue: float = mn
|
|
83
|
+
self.maxValue: float = mx
|
|
84
|
+
self.simplex.sliders.append(self)
|
|
85
|
+
|
|
86
|
+
with self.insertItemManager(group):
|
|
87
|
+
self.group: Group = group
|
|
88
|
+
self.group.items.append(self)
|
|
89
|
+
|
|
90
|
+
newThing = self.DCC.getSliderThing(self._name)
|
|
91
|
+
if newThing is None:
|
|
92
|
+
if create:
|
|
93
|
+
self.thing = simplex.DCC.createSlider(self)
|
|
94
|
+
else:
|
|
95
|
+
raise RuntimeError(f"Unable to find existing shape: {self.name}")
|
|
96
|
+
else:
|
|
97
|
+
self.thing = newThing
|
|
98
|
+
|
|
99
|
+
@property
|
|
100
|
+
def enabled(self) -> bool:
|
|
101
|
+
"""Get whether this Slider is evaluated in the solver"""
|
|
102
|
+
return self._enabled
|
|
103
|
+
|
|
104
|
+
@enabled.setter
|
|
105
|
+
@stackable
|
|
106
|
+
def enabled(self, value: bool) -> None:
|
|
107
|
+
"""Get whether this Slider is evaluated in the solver"""
|
|
108
|
+
self._enabled = value
|
|
109
|
+
|
|
110
|
+
@classmethod
|
|
111
|
+
def createSlider(
|
|
112
|
+
cls,
|
|
113
|
+
name: str,
|
|
114
|
+
simplex: Simplex,
|
|
115
|
+
group: Group | None = None,
|
|
116
|
+
shape: Shape | None = None,
|
|
117
|
+
tVal: float = 1.0,
|
|
118
|
+
) -> Slider:
|
|
119
|
+
"""Create a new slider with a name in a group.
|
|
120
|
+
Possibly create a single default shape for this slider
|
|
121
|
+
|
|
122
|
+
Parameters
|
|
123
|
+
----------
|
|
124
|
+
name : str
|
|
125
|
+
The name of this Slider
|
|
126
|
+
simplex : Simplex
|
|
127
|
+
The parent Simplex system
|
|
128
|
+
group : Group or None
|
|
129
|
+
The group to add the Slider to.
|
|
130
|
+
If None, create a default group. Defaults to None
|
|
131
|
+
shape : Shape or None
|
|
132
|
+
What shape to add to the new Slider's Progression at the given tVal
|
|
133
|
+
if None, create a default shape. Defaults to None
|
|
134
|
+
tVal : float
|
|
135
|
+
The value for the new shape in the Slider's Progression. Defaults to 1.0
|
|
136
|
+
|
|
137
|
+
Returns
|
|
138
|
+
-------
|
|
139
|
+
Slider
|
|
140
|
+
The newly created Slider
|
|
141
|
+
"""
|
|
142
|
+
if simplex.restShape is None:
|
|
143
|
+
raise RuntimeError("Simplex system is missing rest shape")
|
|
144
|
+
|
|
145
|
+
if group is None:
|
|
146
|
+
if simplex.sliderGroups:
|
|
147
|
+
group = simplex.sliderGroups[0]
|
|
148
|
+
else:
|
|
149
|
+
group = Group(f"{name}_GROUP", simplex, Slider)
|
|
150
|
+
|
|
151
|
+
currentNames = [s.name for s in simplex.sliders]
|
|
152
|
+
name = getNextName(name, currentNames)
|
|
153
|
+
|
|
154
|
+
prog = Progression(name, simplex)
|
|
155
|
+
if shape is None:
|
|
156
|
+
prog.createShape(name, tVal)
|
|
157
|
+
else:
|
|
158
|
+
prog.pairs.append(ProgPair(simplex, shape, tVal))
|
|
159
|
+
|
|
160
|
+
sli = cls(name, simplex, prog, group)
|
|
161
|
+
return sli
|
|
162
|
+
|
|
163
|
+
@classmethod
|
|
164
|
+
def createMultiSlider(
|
|
165
|
+
cls,
|
|
166
|
+
name: str,
|
|
167
|
+
simplex: Simplex,
|
|
168
|
+
shapes: list[Shape],
|
|
169
|
+
tVals: list[float],
|
|
170
|
+
group: Group | None = None,
|
|
171
|
+
) -> Slider:
|
|
172
|
+
"""Create a new slider with a name (possibly in a custom group) with the
|
|
173
|
+
provided shapes and t-values.
|
|
174
|
+
|
|
175
|
+
Parameters
|
|
176
|
+
----------
|
|
177
|
+
name : str
|
|
178
|
+
The name of this Slider
|
|
179
|
+
simplex : Simplex
|
|
180
|
+
The parent Simplex system
|
|
181
|
+
shape : list of Shape
|
|
182
|
+
What shape s to add to the new Slider's Progression at the given tVals
|
|
183
|
+
tVal : list of float
|
|
184
|
+
The values for the new shapes in the Slider's Progression
|
|
185
|
+
group : Group or None
|
|
186
|
+
The group to add the Slider to.
|
|
187
|
+
If None, create a default group. Defaults to None
|
|
188
|
+
Returns
|
|
189
|
+
-------
|
|
190
|
+
Slider
|
|
191
|
+
The newly created Slider
|
|
192
|
+
"""
|
|
193
|
+
if simplex.restShape is None:
|
|
194
|
+
raise RuntimeError("Simplex system is missing rest shape")
|
|
195
|
+
|
|
196
|
+
if group is None:
|
|
197
|
+
if simplex.sliderGroups:
|
|
198
|
+
group = simplex.sliderGroups[0]
|
|
199
|
+
else:
|
|
200
|
+
group = Group(f"{name}_GROUP", simplex, Slider)
|
|
201
|
+
|
|
202
|
+
currentNames = [s.name for s in simplex.sliders]
|
|
203
|
+
name = getNextName(name, currentNames)
|
|
204
|
+
|
|
205
|
+
prog = Progression(name, simplex)
|
|
206
|
+
for shape, tVal in zip(shapes, tVals):
|
|
207
|
+
prog.pairs.append(ProgPair(simplex, shape, tVal))
|
|
208
|
+
|
|
209
|
+
sli = cls(name, simplex, prog, group)
|
|
210
|
+
return sli
|
|
211
|
+
|
|
212
|
+
@property
|
|
213
|
+
def name(self) -> str:
|
|
214
|
+
"""Get the name of a Slider"""
|
|
215
|
+
return self._name
|
|
216
|
+
|
|
217
|
+
@name.setter
|
|
218
|
+
@stackable
|
|
219
|
+
def name(self, value: str) -> None:
|
|
220
|
+
"""Set the name of a Slider"""
|
|
221
|
+
self._name = value
|
|
222
|
+
self.prog.name = value
|
|
223
|
+
self.DCC.renameSlider(self, value)
|
|
224
|
+
# TODO Also rename the combos
|
|
225
|
+
|
|
226
|
+
def nameLinks(self) -> list[bool]:
|
|
227
|
+
sp = self._name.split("_")
|
|
228
|
+
sliderPoss = []
|
|
229
|
+
for orig in sp:
|
|
230
|
+
s = caseSplit(orig)
|
|
231
|
+
if len(s) > 1:
|
|
232
|
+
s = [orig] + s
|
|
233
|
+
sliderPoss.append(s)
|
|
234
|
+
|
|
235
|
+
# remove numbered chunks from the end
|
|
236
|
+
shapeNames = []
|
|
237
|
+
shapes = [p.shape for p in self.prog.pairs]
|
|
238
|
+
for s in shapes:
|
|
239
|
+
x = s.name.rsplit("_", 1)
|
|
240
|
+
if len(x) == 2:
|
|
241
|
+
base, sfx = x
|
|
242
|
+
if sfx[0].lower() == "n":
|
|
243
|
+
sfx = sfx[1:]
|
|
244
|
+
x = base if sfx.isdigit() else s.name
|
|
245
|
+
shapeNames.append(x)
|
|
246
|
+
|
|
247
|
+
out = [False] * len(shapeNames)
|
|
248
|
+
for poss in itertools.product(*sliderPoss):
|
|
249
|
+
check = "".join(poss)
|
|
250
|
+
for i, s in enumerate(shapeNames):
|
|
251
|
+
if check == s:
|
|
252
|
+
out[i] = True
|
|
253
|
+
if all(out):
|
|
254
|
+
break
|
|
255
|
+
return out
|
|
256
|
+
|
|
257
|
+
@classmethod
|
|
258
|
+
def buildSliderName(cls, pairs: list[tuple[str, float]]) -> str:
|
|
259
|
+
"""Figure out then name for a slider with given shapes
|
|
260
|
+
|
|
261
|
+
This will mostly be used to figure out what the new name
|
|
262
|
+
for a slider will be if its shapes are renamed
|
|
263
|
+
|
|
264
|
+
Parameters
|
|
265
|
+
----------
|
|
266
|
+
pairs : [(str, float)]
|
|
267
|
+
A list of (name, value) pairs
|
|
268
|
+
|
|
269
|
+
Returns
|
|
270
|
+
-------
|
|
271
|
+
: str
|
|
272
|
+
A newly created name
|
|
273
|
+
"""
|
|
274
|
+
# In this case, pairs is *not* a list of ProgPairs
|
|
275
|
+
# but a list of (name, value) tuples
|
|
276
|
+
|
|
277
|
+
# First, I'm just going to ignore anything with values that aren't 1.0
|
|
278
|
+
# This simplifies the logic greatly
|
|
279
|
+
extPairs = [p for p in pairs if abs(p[1]) == 1.0]
|
|
280
|
+
if len(extPairs) == 1:
|
|
281
|
+
return extPairs[0][0]
|
|
282
|
+
if extPairs[0] == 1:
|
|
283
|
+
extPairs = extPairs[::-1]
|
|
284
|
+
|
|
285
|
+
names = []
|
|
286
|
+
for ep in extPairs:
|
|
287
|
+
sp = ep[0].split("_")
|
|
288
|
+
if Shape.isNumberField(sp[-1]):
|
|
289
|
+
sp = sp[:-1]
|
|
290
|
+
names.append(sp)
|
|
291
|
+
|
|
292
|
+
return "_".join(["".join(makeUnique(n)) for n in names])
|
|
293
|
+
|
|
294
|
+
@property
|
|
295
|
+
def thing(self) -> DCCObject:
|
|
296
|
+
"""Get the stored reference to the DCC attribute"""
|
|
297
|
+
# if this is a deepcopied object, then self._thing will
|
|
298
|
+
# be None. Rebuild the thing connection by its representation
|
|
299
|
+
if self._thing is None and self._thingRepr:
|
|
300
|
+
self._thing = self.DCC.loadPersistentSlider(self._thingRepr)
|
|
301
|
+
return self._thing
|
|
302
|
+
|
|
303
|
+
@thing.setter
|
|
304
|
+
def thing(self, value: DCCObject) -> None:
|
|
305
|
+
self._thing = value
|
|
306
|
+
self._thingRepr = self.DCC.getPersistentSlider(value)
|
|
307
|
+
|
|
308
|
+
@property
|
|
309
|
+
def value(self) -> float:
|
|
310
|
+
"""Get the current value for this Slider"""
|
|
311
|
+
return self._value
|
|
312
|
+
|
|
313
|
+
@value.setter
|
|
314
|
+
def value(self, val: float) -> None:
|
|
315
|
+
"""Set the current value for this Slider"""
|
|
316
|
+
self._value = val
|
|
317
|
+
# singleShot consolidates all
|
|
318
|
+
self._setAllSliders(self) # type: ignore
|
|
319
|
+
|
|
320
|
+
@singleShot()
|
|
321
|
+
def _setAllSliders(self, *sliders: Slider) -> None:
|
|
322
|
+
with undoContext(self.DCC):
|
|
323
|
+
for slider in sliders:
|
|
324
|
+
self.DCC.setSliderWeight(slider, slider.value)
|
|
325
|
+
|
|
326
|
+
def updateValue(self) -> None:
|
|
327
|
+
pass
|
|
328
|
+
|
|
329
|
+
@classmethod
|
|
330
|
+
def loadV2(
|
|
331
|
+
cls,
|
|
332
|
+
simplex: Simplex,
|
|
333
|
+
progs: list[Progression],
|
|
334
|
+
data: dict[str, Any],
|
|
335
|
+
create: bool,
|
|
336
|
+
) -> Slider:
|
|
337
|
+
"""Load the data from a version2 formatted json dictionary
|
|
338
|
+
|
|
339
|
+
Parameters
|
|
340
|
+
----------
|
|
341
|
+
simplex : Simplex
|
|
342
|
+
The Simplex system that's being built
|
|
343
|
+
progs : [Progression
|
|
344
|
+
The progressions that have already been built
|
|
345
|
+
data : dict
|
|
346
|
+
The chunk of the json dict used to build this object
|
|
347
|
+
create : bool
|
|
348
|
+
Whether to create the DCC Shape, or look for it already in-scene
|
|
349
|
+
|
|
350
|
+
Returns
|
|
351
|
+
-------
|
|
352
|
+
: Slider
|
|
353
|
+
The specified Slider
|
|
354
|
+
"""
|
|
355
|
+
name = data["name"]
|
|
356
|
+
prog = progs[data["prog"]]
|
|
357
|
+
group = simplex.groups[data.get("group", 0)]
|
|
358
|
+
return cls(name, simplex, prog, group, create=create)
|
|
359
|
+
|
|
360
|
+
def buildDefinition(self, simpDict: dict[str, Any], legacy: bool) -> int:
|
|
361
|
+
"""Output a dictionary definition of this object
|
|
362
|
+
|
|
363
|
+
Parameters
|
|
364
|
+
----------
|
|
365
|
+
simpDict : dict
|
|
366
|
+
The dictionary that is being built
|
|
367
|
+
legacy : bool
|
|
368
|
+
Whether to write out the legacy definition, or the newer one
|
|
369
|
+
|
|
370
|
+
Returns
|
|
371
|
+
-------
|
|
372
|
+
: int
|
|
373
|
+
The build index
|
|
374
|
+
"""
|
|
375
|
+
if self._buildIdx is None:
|
|
376
|
+
self._buildIdx = len(simpDict["sliders"])
|
|
377
|
+
if legacy:
|
|
378
|
+
gIdx = self.group.buildDefinition(simpDict, legacy)
|
|
379
|
+
pIdx = self.prog.buildDefinition(simpDict, legacy)
|
|
380
|
+
simpDict.setdefault("sliders", []).append([self.name, pIdx, gIdx])
|
|
381
|
+
else:
|
|
382
|
+
x = {
|
|
383
|
+
"name": self.name,
|
|
384
|
+
"prog": self.prog.buildDefinition(simpDict, legacy),
|
|
385
|
+
"group": self.group.buildDefinition(simpDict, legacy),
|
|
386
|
+
"enabled": self._enabled,
|
|
387
|
+
}
|
|
388
|
+
simpDict.setdefault("sliders", []).append(x)
|
|
389
|
+
return self._buildIdx
|
|
390
|
+
|
|
391
|
+
def clearBuildIndex(self) -> None:
|
|
392
|
+
"""Clear the build index of this object
|
|
393
|
+
|
|
394
|
+
The buildIndex is stored when building a definition dictionary
|
|
395
|
+
that keeps track of its index for later referencing
|
|
396
|
+
"""
|
|
397
|
+
self._buildIdx = None
|
|
398
|
+
self.prog.clearBuildIndex()
|
|
399
|
+
self.group.clearBuildIndex()
|
|
400
|
+
|
|
401
|
+
def setRange(self) -> None:
|
|
402
|
+
"""Set the range of this Slider based on the progPair values"""
|
|
403
|
+
values = [i.value for i in self.prog.pairs]
|
|
404
|
+
self.minValue = min(values)
|
|
405
|
+
self.maxValue = max(values)
|
|
406
|
+
self.DCC.setSliderRange(self)
|
|
407
|
+
|
|
408
|
+
@stackable
|
|
409
|
+
def delete(self) -> None:
|
|
410
|
+
"""Delete a slider, any shapes it contains, and all downstream Combos and Traversals"""
|
|
411
|
+
self.simplex.deleteDownstream(self)
|
|
412
|
+
with self.removeItemManager(self):
|
|
413
|
+
g = self.group
|
|
414
|
+
g.items.remove(self)
|
|
415
|
+
self.group = None # type: ignore
|
|
416
|
+
self.simplex.sliders.remove(self)
|
|
417
|
+
|
|
418
|
+
pairs = self.prog.pairs[:] # gotta make a copy
|
|
419
|
+
for pp in pairs:
|
|
420
|
+
if not pp.shape.isRest:
|
|
421
|
+
self.simplex.shapes.remove(pp.shape)
|
|
422
|
+
self.DCC.deleteShape(pp.shape)
|
|
423
|
+
|
|
424
|
+
self.DCC.deleteSlider(self)
|
|
425
|
+
|
|
426
|
+
@stackable
|
|
427
|
+
def setInterpolation(self, interp: str) -> None:
|
|
428
|
+
"""Set the interpolation of a single Slider
|
|
429
|
+
|
|
430
|
+
Parameters
|
|
431
|
+
----------
|
|
432
|
+
interp : str
|
|
433
|
+
The interpolation for this Slider's Progression
|
|
434
|
+
"""
|
|
435
|
+
self.prog.interp = interp
|
|
436
|
+
|
|
437
|
+
@stackable
|
|
438
|
+
def setInterps(self, sliders: list[Slider], interp: str) -> None:
|
|
439
|
+
"""Set the interpolation of multiple Sliders
|
|
440
|
+
|
|
441
|
+
Parameters
|
|
442
|
+
----------
|
|
443
|
+
sliders : [Slider
|
|
444
|
+
List of sliders to set interpolations on
|
|
445
|
+
interp : str
|
|
446
|
+
The interpolation to set on the list of Sliders
|
|
447
|
+
"""
|
|
448
|
+
# This uses an instantiated slider to set the values
|
|
449
|
+
# of multiple sliders. This is so we don't update the
|
|
450
|
+
# DCC over and over again
|
|
451
|
+
if not sliders:
|
|
452
|
+
return
|
|
453
|
+
with undoContext(self.DCC):
|
|
454
|
+
for slider in sliders:
|
|
455
|
+
slider.prog.interp = interp
|
|
456
|
+
|
|
457
|
+
@stackable
|
|
458
|
+
def createShape(
|
|
459
|
+
self, shapeName: str | None = None, tVal: float | None = None
|
|
460
|
+
) -> ProgPair:
|
|
461
|
+
"""Create a shape and add it to a progression
|
|
462
|
+
|
|
463
|
+
Parameters
|
|
464
|
+
----------
|
|
465
|
+
shapeName : str or None
|
|
466
|
+
The new Shape name in this Slider's Progression.
|
|
467
|
+
If None, give it a default name. Defaults to None
|
|
468
|
+
tVal : float or None
|
|
469
|
+
The value to give the shape in this Slider's Progression.
|
|
470
|
+
If None, give it a "smart" default. Defaults to None
|
|
471
|
+
|
|
472
|
+
Returns
|
|
473
|
+
-------
|
|
474
|
+
: ProgPair
|
|
475
|
+
The newly created Shape in a ProgPair already added to the Progression
|
|
476
|
+
"""
|
|
477
|
+
pp, idx = self.prog.newProgPair(shapeName, tVal)
|
|
478
|
+
with self.insertItemManager(self, row=idx):
|
|
479
|
+
pp.prog = self.prog
|
|
480
|
+
self.prog.pairs.insert(idx, pp)
|
|
481
|
+
self.updateRange()
|
|
482
|
+
return pp
|
|
483
|
+
|
|
484
|
+
def extractProgressive(
|
|
485
|
+
self, live: bool = True, offset: float = 10.0, separation: float = 5.0
|
|
486
|
+
) -> None:
|
|
487
|
+
"""Extract all of the Shapes in this Slider's Progression
|
|
488
|
+
|
|
489
|
+
Parameters
|
|
490
|
+
----------
|
|
491
|
+
live : bool
|
|
492
|
+
Whether to maintain a live connection in the DCC for the extracted meshes
|
|
493
|
+
Defaults to True
|
|
494
|
+
offset : float
|
|
495
|
+
The offset value for the first extracted mesh in the DCC (Default value = 10.0)
|
|
496
|
+
separation : float
|
|
497
|
+
The offset to add between any two extracted meshes (Default value = 5.0)
|
|
498
|
+
"""
|
|
499
|
+
with undoContext(self.DCC):
|
|
500
|
+
pos, neg = [], []
|
|
501
|
+
for pp in sorted(self.prog.pairs):
|
|
502
|
+
if pp.value < 0.0:
|
|
503
|
+
neg.append((pp.value, pp.shape, offset))
|
|
504
|
+
offset += separation
|
|
505
|
+
elif pp.value > 0.0:
|
|
506
|
+
pos.append((pp.value, pp.shape, offset))
|
|
507
|
+
offset += separation
|
|
508
|
+
# skip the rest value at == 0.0
|
|
509
|
+
neg = list(reversed(neg))
|
|
510
|
+
|
|
511
|
+
for prog in [pos, neg]:
|
|
512
|
+
if not prog:
|
|
513
|
+
continue
|
|
514
|
+
xtVal, shape, shift = prog[-1]
|
|
515
|
+
ret = self.DCC.extractWithDeltaShape(shape, live, shift)
|
|
516
|
+
if ret is not None:
|
|
517
|
+
ext, deltaShape = ret
|
|
518
|
+
for value, shape, shift in prog[:-1]:
|
|
519
|
+
self.DCC.extractWithDeltaConnection(
|
|
520
|
+
shape, deltaShape, value / xtVal, live, shift
|
|
521
|
+
)
|
|
522
|
+
|
|
523
|
+
def extractShape(
|
|
524
|
+
self, shape: Shape, live: bool = True, offset: float = 10.0
|
|
525
|
+
) -> DCCObject:
|
|
526
|
+
"""Extract a Shape that is controlled by a Slider to a DCC mesh
|
|
527
|
+
|
|
528
|
+
This is on Slider (vs being on Shape) because live connections are handled
|
|
529
|
+
differently based on the different Progression controllers
|
|
530
|
+
|
|
531
|
+
Parameters
|
|
532
|
+
----------
|
|
533
|
+
shape : Shape
|
|
534
|
+
The shape to extract
|
|
535
|
+
live :
|
|
536
|
+
(Default value = True)
|
|
537
|
+
offset : float
|
|
538
|
+
The offset value for the first extracted mesh in the DCC (Default value = 10.0)
|
|
539
|
+
"""
|
|
540
|
+
return self.DCC.extractShape(shape, live, offset)
|
|
541
|
+
|
|
542
|
+
def connectShape(
|
|
543
|
+
self,
|
|
544
|
+
shape: Shape,
|
|
545
|
+
mesh: DCCObject | None = None,
|
|
546
|
+
live: bool = False,
|
|
547
|
+
delete: bool = False,
|
|
548
|
+
) -> None:
|
|
549
|
+
"""Connect a Shape that is controlled by a Slider to a DCC mesh
|
|
550
|
+
|
|
551
|
+
This is on Slider (vs being on Shape) because live connections are handled
|
|
552
|
+
differently based on the different Progression controllers
|
|
553
|
+
|
|
554
|
+
Parameters
|
|
555
|
+
----------
|
|
556
|
+
shape : Shape
|
|
557
|
+
The shape to connect
|
|
558
|
+
mesh : object or None
|
|
559
|
+
The DCC mesh to connect to the shape.
|
|
560
|
+
If None, search the DCC by name. Defaults to None
|
|
561
|
+
live : bool
|
|
562
|
+
Whether to maintain a live connection in the DCC for the extracted meshes
|
|
563
|
+
Defaults to True
|
|
564
|
+
delete : bool
|
|
565
|
+
Whether to delete the DCC mesh after it was connected (Default value = False)
|
|
566
|
+
"""
|
|
567
|
+
self.DCC.connectShape(shape, mesh, live, delete)
|
|
568
|
+
|
|
569
|
+
def updateRange(self) -> None:
|
|
570
|
+
"""Update the range in the DCC for this Slider"""
|
|
571
|
+
self.DCC.updateSlidersRange([self])
|
|
572
|
+
|
|
573
|
+
@stackable
|
|
574
|
+
def setGroup(self, grp: Group) -> None:
|
|
575
|
+
"""Set the Group for this Slider
|
|
576
|
+
|
|
577
|
+
Parameters
|
|
578
|
+
----------
|
|
579
|
+
grp : Group
|
|
580
|
+
The Group to put this Slider under
|
|
581
|
+
"""
|
|
582
|
+
if grp.groupType is None:
|
|
583
|
+
grp.groupType = type(self)
|
|
584
|
+
|
|
585
|
+
if not isinstance(self, grp.groupType):
|
|
586
|
+
raise ValueError(
|
|
587
|
+
f"All items in this group must be of type: {grp.groupType}"
|
|
588
|
+
)
|
|
589
|
+
|
|
590
|
+
with self.moveItemManager(self, grp):
|
|
591
|
+
if self.group:
|
|
592
|
+
self.group.items.remove(self)
|
|
593
|
+
grp.items.append(self)
|
|
594
|
+
self.group = grp
|
|
595
|
+
|
|
596
|
+
def getInputVectors(self) -> list[list[float]]:
|
|
597
|
+
"""Get the ordered values for input to the solver that activate this Slider
|
|
598
|
+
Multiple outputs are possible if the slider has -1 to 1 range
|
|
599
|
+
|
|
600
|
+
Returns
|
|
601
|
+
-------
|
|
602
|
+
: [[float, ....], ....]
|
|
603
|
+
The ordered slider values
|
|
604
|
+
"""
|
|
605
|
+
inVecs = []
|
|
606
|
+
for pp in self.prog.getExtremePairs():
|
|
607
|
+
inVec = [0.0] * len(self.simplex.sliders)
|
|
608
|
+
inVec[self.simplex.sliders.index(self)] = pp.value
|
|
609
|
+
inVecs.append(inVec)
|
|
610
|
+
return inVecs
|
|
611
|
+
|
|
612
|
+
def treeChild(self, row: int) -> TreeItem:
|
|
613
|
+
return self.prog.pairs[row]
|
|
614
|
+
|
|
615
|
+
def treeRow(self) -> int:
|
|
616
|
+
return self.group.items.index(self)
|
|
617
|
+
|
|
618
|
+
def treeParent(self) -> TreeItem:
|
|
619
|
+
return self.group
|
|
620
|
+
|
|
621
|
+
def treeChildCount(self) -> int:
|
|
622
|
+
return len(self.prog.pairs)
|
|
623
|
+
|
|
624
|
+
def treeData(self, column: int) -> Any | None:
|
|
625
|
+
if column == 0:
|
|
626
|
+
return self.name
|
|
627
|
+
if column == 1:
|
|
628
|
+
return self.value
|
|
629
|
+
return None
|
|
630
|
+
|
|
631
|
+
def treeChecked(self) -> bool:
|
|
632
|
+
return self.enabled
|