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.
Files changed (79) hide show
  1. simplex_solver-3.1.0.dist-info/METADATA +90 -0
  2. simplex_solver-3.1.0.dist-info/RECORD +79 -0
  3. simplex_solver-3.1.0.dist-info/WHEEL +5 -0
  4. simplexui/__init__.py +53 -0
  5. simplexui/_version.py +1 -0
  6. simplexui/channelBox.py +858 -0
  7. simplexui/comboCheckDialog.py +343 -0
  8. simplexui/commands/__init__.py +16 -0
  9. simplexui/commands/alembicCommon.py +991 -0
  10. simplexui/commands/applyCorrectives.py +451 -0
  11. simplexui/commands/correctiveInterface.py +261 -0
  12. simplexui/commands/expandedExport.py +436 -0
  13. simplexui/commands/hdf5Convert.py +60 -0
  14. simplexui/commands/mayaCorrectiveInterface.py +161 -0
  15. simplexui/commands/mayatonumpy.py +375 -0
  16. simplexui/commands/mesh.py +1081 -0
  17. simplexui/commands/numpytoimath.py +319 -0
  18. simplexui/commands/poseblendlib.py +166 -0
  19. simplexui/commands/reorderSimplexPoints.py +102 -0
  20. simplexui/commands/rigidAlign.py +99 -0
  21. simplexui/commands/smpxBlend.py +629 -0
  22. simplexui/commands/unsubdivide.py +1227 -0
  23. simplexui/commands/uvTransfer.py +977 -0
  24. simplexui/dragFilter.py +299 -0
  25. simplexui/falloffDialog.py +471 -0
  26. simplexui/img/ChefHead.png +0 -0
  27. simplexui/img/frozen.png +0 -0
  28. simplexui/interface/__init__.py +28 -0
  29. simplexui/interface/dummyInterface.py +1585 -0
  30. simplexui/interface/mayaInterface.py +3271 -0
  31. simplexui/interfaceModel.py +1053 -0
  32. simplexui/interfaceModelTrees.py +441 -0
  33. simplexui/items/__init__.py +42 -0
  34. simplexui/items/accessor.py +213 -0
  35. simplexui/items/combo.py +852 -0
  36. simplexui/items/falloff.py +778 -0
  37. simplexui/items/group.py +297 -0
  38. simplexui/items/progression.py +743 -0
  39. simplexui/items/shape.py +443 -0
  40. simplexui/items/simplex.py +1764 -0
  41. simplexui/items/slider.py +738 -0
  42. simplexui/items/stack.py +154 -0
  43. simplexui/items/traversal.py +966 -0
  44. simplexui/main.pyw +22 -0
  45. simplexui/menu/__init__.py +69 -0
  46. simplexui/menu/dummyPlugins/__init__.py +16 -0
  47. simplexui/menu/genericPlugins/__init__.py +16 -0
  48. simplexui/menu/genericPlugins/_builtins.py +268 -0
  49. simplexui/menu/genericPlugins/checkPossibleCombos.py +45 -0
  50. simplexui/menu/genericPlugins/exportSplit.py +59 -0
  51. simplexui/menu/genericPlugins/showFalloffs.py +24 -0
  52. simplexui/menu/genericPlugins/showTraversals.py +24 -0
  53. simplexui/menu/genericPlugins/simplexUvTransfer.py +107 -0
  54. simplexui/menu/genericPlugins/unsubdivide.py +70 -0
  55. simplexui/menu/mayaPlugins/__init__.py +16 -0
  56. simplexui/menu/mayaPlugins/exportOther.py +43 -0
  57. simplexui/menu/mayaPlugins/extractProgressives.py +65 -0
  58. simplexui/menu/mayaPlugins/freezeCombo.py +245 -0
  59. simplexui/menu/mayaPlugins/generateShapeIncrementals.py +97 -0
  60. simplexui/menu/mayaPlugins/importObjs.py +193 -0
  61. simplexui/menu/mayaPlugins/linearizeTraversal.py +48 -0
  62. simplexui/menu/mayaPlugins/makeShelfBtn.py +65 -0
  63. simplexui/menu/mayaPlugins/relaxToSelection.py +75 -0
  64. simplexui/menu/mayaPlugins/reloadDefinition.py +33 -0
  65. simplexui/menu/mayaPlugins/snapToNeutral.py +72 -0
  66. simplexui/menu/mayaPlugins/softSelectToCluster.py +200 -0
  67. simplexui/menu/mayaPlugins/tweakMix.py +134 -0
  68. simplexui/menu/mayaPlugins/updateRestShape.py +105 -0
  69. simplexui/pysimplex.dll.a +0 -0
  70. simplexui/pysimplex.pyd +0 -0
  71. simplexui/simplexDialog.py +1454 -0
  72. simplexui/travCheckDialog.py +397 -0
  73. simplexui/traversalDialog.py +271 -0
  74. simplexui/ui/comboCheckDialog.ui +475 -0
  75. simplexui/ui/falloffDialog.ui +243 -0
  76. simplexui/ui/simplexDialog.ui +1458 -0
  77. simplexui/ui/travCheckDialog.ui +488 -0
  78. simplexui/ui/traversalDialog.ui +532 -0
  79. simplexui/utils.py +320 -0
@@ -0,0 +1,852 @@
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 ..interface import undoContext
19
+
20
+ # pylint:disable=missing-docstring,unused-argument,no-self-use
21
+ from Qt.QtGui import QColor
22
+ from ..utils import getIcon, nested
23
+ from .accessor import SimplexAccessor
24
+ from .stack import stackable
25
+
26
+
27
+ # Abstract Items
28
+ class ComboPair(SimplexAccessor):
29
+ """A Slider/Value pair for use in Combos"""
30
+
31
+ classDepth = 6
32
+
33
+ def __init__(self, slider, value):
34
+ simplex = slider.simplex
35
+ super(ComboPair, self).__init__(simplex)
36
+ self.slider = slider
37
+ self._value = float(value)
38
+ self.minValue = -1.0
39
+ self.maxValue = 1.0
40
+ self.combo = None
41
+ self.expanded = {}
42
+
43
+ @property
44
+ def models(self):
45
+ """ """
46
+ return self.combo.simplex.models
47
+
48
+ @property
49
+ def name(self):
50
+ """ """
51
+ return self.slider.name
52
+
53
+ @property
54
+ def value(self):
55
+ """ """
56
+ return self._value
57
+
58
+ @value.setter
59
+ @stackable
60
+ def value(self, val):
61
+ """
62
+
63
+ Parameters
64
+ ----------
65
+ val :
66
+
67
+
68
+ Returns
69
+ -------
70
+
71
+ """
72
+ self._value = val
73
+ for model in self.models:
74
+ model.itemDataChanged(self)
75
+
76
+ def buildDefinition(self, simpDict, legacy):
77
+ """
78
+
79
+ Parameters
80
+ ----------
81
+ simpDict :
82
+
83
+ legacy :
84
+
85
+
86
+ Returns
87
+ -------
88
+
89
+ """
90
+ sIdx = self.slider.buildDefinition(simpDict, legacy)
91
+ return sIdx, self.value
92
+
93
+ def treeRow(self):
94
+ """ """
95
+ return self.combo.pairs.index(self)
96
+
97
+ def treeParent(self):
98
+ """ """
99
+ return self.combo
100
+
101
+ def treeData(self, column):
102
+ """
103
+
104
+ Parameters
105
+ ----------
106
+ column :
107
+
108
+
109
+ Returns
110
+ -------
111
+
112
+ """
113
+ if column == 0:
114
+ return self.name
115
+ if column == 1:
116
+ return self.value
117
+ return None
118
+
119
+
120
+ class Combo(SimplexAccessor):
121
+ """A group of Slider/Value pairs that control a Progression through some solver
122
+
123
+ Combos allow for fixit shapes to be created for any number of user inputs.
124
+ They also allow for fixits along the progression, and in "floating space" where
125
+ the inputs are not -1 or 1
126
+
127
+ Parameters
128
+ ----------
129
+ name : str
130
+ The name of this Combo
131
+ simplex : Simplex
132
+ The parent Simplex system
133
+ pairs : [ComboPair
134
+ The Slider/Value pairs that make up this combo
135
+ prog : Progression
136
+ The Progression that this Combo controls
137
+ group : Group
138
+ The Group to create this combo in
139
+ solveType : str
140
+ The solve type for this combo. See Combo.solveTypes for a list
141
+ color : QColor
142
+ The color of this item in the UI
143
+
144
+ Returns
145
+ -------
146
+
147
+ """
148
+
149
+ classDepth = 5
150
+ solveTypes = (
151
+ ("Minimum", "min"),
152
+ ("Multiply All", "allMul"),
153
+ ("Multiply Extremes", "extMul"),
154
+ ("Multiply Avg of Extremes", "mulAvgExt"),
155
+ ("Multiply Avg", "mulAvgAll"),
156
+ ("None", "min"),
157
+ )
158
+ _freezeIcon = None
159
+
160
+ def __init__(self, name, simplex, pairs, prog, group, solveType, color=None):
161
+ super(Combo, self).__init__(simplex)
162
+ color = QColor(128, 128, 128) if color is None else color
163
+
164
+ with self.stack.store(self):
165
+ if group.groupType is not type(self):
166
+ raise ValueError("Cannot add this slider to a combo group")
167
+ self._name = name
168
+ self.pairs = pairs
169
+ self.prog = prog
170
+ self._solveType = solveType
171
+ self._buildIdx = None
172
+ self.expanded = {}
173
+ self._enabled = True
174
+ self.color = color
175
+
176
+ self._freezeThing = None
177
+
178
+ mgrs = [model.insertItemManager(group) for model in self.models]
179
+ with nested(*mgrs):
180
+ self.group = group
181
+ for p in self.pairs:
182
+ p.combo = self
183
+ self.prog.controller = self
184
+ self.group.items.append(self)
185
+ self.simplex.combos.append(self)
186
+
187
+ @property
188
+ def enabled(self):
189
+ """Get whether this Combo is evaluated in the solver"""
190
+ return self._enabled
191
+
192
+ @enabled.setter
193
+ @stackable
194
+ def enabled(self, value):
195
+ """Set whether this Combo is evaluated in the solver"""
196
+ self._enabled = value
197
+ for model in self.models:
198
+ model.itemDataChanged(self)
199
+
200
+ @property
201
+ def frozen(self):
202
+ """Get whether this Combo is frozen"""
203
+ return bool(self.freezeThing)
204
+
205
+ @property
206
+ def freezeThing(self):
207
+ """Get whether this Combo is frozen"""
208
+ if self._freezeThing is None:
209
+ self._freezeThing = self.DCC.getFreezeThing(self)
210
+ return self._freezeThing
211
+
212
+ @freezeThing.setter
213
+ def freezeThing(self, value):
214
+ self._freezeThing = value
215
+ for model in self.models:
216
+ model.itemDataChanged(self)
217
+
218
+ def icon(self):
219
+ if self.frozen:
220
+ if self._freezeIcon is None:
221
+ type(self)._freezeIcon = getIcon("frozen.png")
222
+ return self._freezeIcon
223
+ return None
224
+
225
+ @classmethod
226
+ def comboAlreadyExists(cls, simplex, sliders, values):
227
+ """Classmethod to check whether a combo already exists with these sliders and values
228
+
229
+ Parameters
230
+ ----------
231
+ simplex : Simplex
232
+ The system to check within
233
+ sliders : [Slider
234
+ The Sliders to check
235
+ values : [float
236
+ The values to zip with the sliders
237
+
238
+ Returns
239
+ -------
240
+ : Combo or None
241
+ The combo that exists with the given values, or None if none exist
242
+
243
+ """
244
+ checker = {(s.name, v) for s, v in zip(sliders, values)}
245
+ for combo in simplex.combos:
246
+ tester = {(p.slider.name, p.value) for p in combo.pairs}
247
+ if checker == tester:
248
+ return combo
249
+ return None
250
+
251
+ @classmethod
252
+ def createCombo(
253
+ cls,
254
+ name,
255
+ simplex,
256
+ sliders,
257
+ values,
258
+ group=None,
259
+ shape=None,
260
+ solveType=None,
261
+ tVal=1.0,
262
+ ):
263
+ """Classmethod to create Combo with some hard-coded defaults
264
+
265
+ Parameters
266
+ ----------
267
+ name : str
268
+ The name of the Combo
269
+ simplex : Simplex
270
+ The Simplex system
271
+ sliders : [Slider
272
+ The Sliders that will control this combo
273
+ values : [float
274
+ The values at which the sliders will activate this combo
275
+ group : Group or None
276
+ A Group to organize this combo.
277
+ If None, the combo will be sorted into a "DEPTH" group (Default value = None)
278
+ shape : Shape or None
279
+ A Shape for this Combo's Progression. If None, then a default shape will be created
280
+ solveType : str or None
281
+ The solve type for this Combo. if None, defaults to 'min' in the solver
282
+ tVal : float
283
+ The slideValue where the Shape will be created/added. Defaults to 1.0
284
+
285
+ Returns
286
+ -------
287
+ : Combo
288
+ The newly created Combo
289
+
290
+ """
291
+ if simplex.restShape is None:
292
+ raise RuntimeError("Simplex system is missing rest shape")
293
+
294
+ # Make sure to check if this combo already exists. If so, just return it
295
+ exist = cls.comboAlreadyExists(simplex, sliders, values)
296
+ if exist is not None:
297
+ return exist
298
+ from .group import Group
299
+ from .progression import ProgPair, Progression
300
+
301
+ if group is None:
302
+ gname = "DEPTH_{0}".format(len(sliders))
303
+ matches = [i for i in simplex.comboGroups if i.name == gname]
304
+ if matches:
305
+ group = matches[0]
306
+ else:
307
+ group = Group(gname, simplex, Combo)
308
+
309
+ cPairs = [ComboPair(slider, value) for slider, value in zip(sliders, values)]
310
+ prog = Progression(name, simplex)
311
+ if shape:
312
+ prog.pairs.append(ProgPair(simplex, shape, tVal))
313
+
314
+ cmb = Combo(name, simplex, cPairs, prog, group, solveType)
315
+
316
+ if shape is None:
317
+ pp = prog.createShape(name, tVal)
318
+ simplex.DCC.zeroShape(pp.shape)
319
+
320
+ return cmb
321
+
322
+ @staticmethod
323
+ def buildComboName(sliders, values):
324
+ """Build the name for a combo based on the input Sliders and values
325
+ The sliders will be alphabetically sorted
326
+ Values not at Shape increments within the progression will get numeric
327
+ suffixes. Negative values will have suffixes like "n75"
328
+
329
+ Parameters
330
+ ----------
331
+ sliders : [Slider
332
+ The sliders to check
333
+ values : [float
334
+ The values for the sliders
335
+
336
+ Returns
337
+ -------
338
+ : str
339
+ The suggested combo name
340
+
341
+ """
342
+ pairs = list(zip(sliders, values))
343
+ pairs = sorted(pairs, key=lambda x: x[0].name)
344
+ parts = []
345
+ for slider, value in pairs:
346
+ shape = slider.prog.getShapeAtValue(value)
347
+ if shape is not None:
348
+ parts.append(shape.name)
349
+ else:
350
+ # get the extreme shape and percentage-ize its name
351
+ extVal = 1.0 if value > 0.0 else -1.0
352
+
353
+ valName = "{}".format(abs(int(value * 100)))
354
+ valName = "n" + valName if value < 0.0 else valName
355
+
356
+ shape = slider.prog.getShapeAtValue(extVal)
357
+ if shape is not None:
358
+ sn = shape.name
359
+ sn = sn.split("_")
360
+ if sn[-1].isnumeric() or (
361
+ sn[-1][0] == "n" and sn[-1][1:].isnumeric()
362
+ ):
363
+ sn[-1] = valName
364
+ else:
365
+ sn.append(valName)
366
+ nsn = "_".join(sn)
367
+ parts.append(nsn)
368
+ else:
369
+ parts.append(slider.name)
370
+
371
+ return "_".join(parts)
372
+
373
+ @property
374
+ def name(self):
375
+ """Get the name of a combo"""
376
+ return self._name
377
+
378
+ @name.setter
379
+ @stackable
380
+ def name(self, value):
381
+ """Set the name of a combo
382
+
383
+ Parameters
384
+ ----------
385
+ value :
386
+
387
+
388
+ Returns
389
+ -------
390
+
391
+ """
392
+ self._name = value
393
+ self.prog.name = value
394
+ self.DCC.renameCombo(self, value)
395
+ for model in self.models:
396
+ model.itemDataChanged(self)
397
+
398
+ @property
399
+ def solveType(self):
400
+ """ """
401
+ return self._solveType
402
+
403
+ @solveType.setter
404
+ @stackable
405
+ def solveType(self, newType):
406
+ """Set the solveType of the combo
407
+
408
+ Parameters
409
+ ----------
410
+ newType :
411
+
412
+
413
+ Returns
414
+ -------
415
+
416
+ """
417
+ stNames, stVals = list(zip(*self.solveTypes))
418
+ if newType not in stVals:
419
+ raise ValueError(
420
+ "Solve Type {0} not in allowed types {1}".format(newType, stVals)
421
+ )
422
+ self._solveType = newType
423
+ for model in self.models:
424
+ model.itemDataChanged(self)
425
+
426
+ def treeChild(self, row):
427
+ """
428
+
429
+ Parameters
430
+ ----------
431
+ row :
432
+
433
+
434
+ Returns
435
+ -------
436
+ type
437
+
438
+
439
+ """
440
+ if row == len(self.pairs):
441
+ return self.prog
442
+ return self.pairs[row]
443
+
444
+ def treeRow(self):
445
+ """ """
446
+ return self.group.items.index(self)
447
+
448
+ def treeParent(self):
449
+ """ """
450
+ return self.group
451
+
452
+ def treeChildCount(self):
453
+ """ """
454
+ return len(self.pairs) + 1
455
+
456
+ def treeChecked(self):
457
+ """ """
458
+ return self.enabled
459
+
460
+ def sliderNameLinks(self):
461
+ """ """
462
+ sliNames = ["_{0}_".format(i.slider.name) for i in self.pairs]
463
+ surr = "_{0}_".format(self.name)
464
+ return [sn in surr for sn in sliNames]
465
+
466
+ def nameLinks(self):
467
+ """
468
+
469
+ Parameters
470
+ ----------
471
+
472
+ Returns
473
+ -------
474
+ : type
475
+ progression depends on this slider's name
476
+
477
+ """
478
+ # In this case, these names will *NOT* have the possibility of
479
+ # a pos/neg name. Only the combo name, and possibly a percentage
480
+ shapeNames = []
481
+ shapes = [i.shape for i in self.prog.pairs]
482
+ for s in shapes:
483
+ x = s.name.rsplit("_", 1)
484
+ if len(x) == 2:
485
+ base, sfx = x
486
+ x = base if sfx.isdigit() else s.name
487
+ shapeNames.append(x)
488
+ return [i == self.name for i in shapeNames]
489
+
490
+ def getSliderIndex(self, slider):
491
+ """
492
+
493
+ Parameters
494
+ ----------
495
+ slider :
496
+
497
+
498
+ Returns
499
+ -------
500
+ type
501
+
502
+
503
+ """
504
+ for i, p in enumerate(self.pairs):
505
+ if p.slider == slider:
506
+ return i
507
+ raise ValueError("Provided slider:{0} is not in the list".format(slider.name))
508
+
509
+ def isFloating(self):
510
+ """
511
+
512
+ Parameters
513
+ ----------
514
+
515
+ Returns
516
+ -------
517
+ : type
518
+ Floating combos are combos that Slider values that are between 0 and 1
519
+
520
+ """
521
+ for pair in self.pairs:
522
+ if abs(pair.value) != 1.0:
523
+ return True
524
+ return False
525
+
526
+ def getSliders(self):
527
+ """ """
528
+ return [i.slider for i in self.pairs]
529
+
530
+ @classmethod
531
+ def loadV2(cls, simplex, progs, data):
532
+ """Load the data from a version2 formatted json dictionary
533
+
534
+ Parameters
535
+ ----------
536
+ simplex : Simplex
537
+ The Simplex system that's being built
538
+ progs : [Progression
539
+ The progressions that have already been built
540
+ data : dict
541
+ The chunk of the json dict used to build this object
542
+
543
+ Returns
544
+ -------
545
+ : Combo
546
+ The specified combo
547
+
548
+ """
549
+ name = data["name"]
550
+ prog = progs[data["prog"]]
551
+ group = simplex.groups[data.get("group", 1)]
552
+ color = QColor(*data.get("color", (128, 128, 128)))
553
+ pairs = [ComboPair(simplex.sliders[s], v) for s, v in data["pairs"]]
554
+ solveType = data.get("solveType")
555
+ return cls(name, simplex, pairs, prog, group, solveType, color=color)
556
+
557
+ def buildDefinition(self, simpDict, legacy):
558
+ """Output a dictionary definition of this object
559
+
560
+ Parameters
561
+ ----------
562
+ simpDict : dict
563
+ The dictionary that is being built
564
+ legacy : bool
565
+ Whether to write out the legacy definition, or the newer one
566
+
567
+ Returns
568
+ -------
569
+
570
+ """
571
+ if self._buildIdx is None:
572
+ self._buildIdx = len(simpDict["combos"])
573
+ if legacy:
574
+ gIdx = self.group.buildDefinition(simpDict, legacy)
575
+ pIdx = self.prog.buildDefinition(simpDict, legacy)
576
+ idxPairs = [p.buildDefinition(simpDict, legacy) for p in self.pairs]
577
+ x = [self.name, pIdx, idxPairs, gIdx]
578
+ simpDict.setdefault("combos", []).append(x)
579
+ else:
580
+ x = {
581
+ "name": self.name,
582
+ "prog": self.prog.buildDefinition(simpDict, legacy),
583
+ "pairs": [p.buildDefinition(simpDict, legacy) for p in self.pairs],
584
+ "group": self.group.buildDefinition(simpDict, legacy),
585
+ "color": self.color.getRgb()[:3],
586
+ "enabled": self._enabled,
587
+ "solveType": str(self._solveType),
588
+ }
589
+ simpDict.setdefault("combos", []).append(x)
590
+ return self._buildIdx
591
+
592
+ def clearBuildIndex(self):
593
+ """Clear the build index of this object
594
+
595
+ The buildIndex is stored when building a definition dictionary
596
+ that keeps track of its index for later referencing
597
+
598
+ Parameters
599
+ ----------
600
+
601
+ Returns
602
+ -------
603
+
604
+ """
605
+ self._buildIdx = None
606
+ self.prog.clearBuildIndex()
607
+ self.group.clearBuildIndex()
608
+
609
+ def extractProgressive(self, live=True, offset=10.0, separation=5.0):
610
+ """
611
+
612
+ Parameters
613
+ ----------
614
+ live :
615
+ (Default value = True)
616
+ offset :
617
+ (Default value = 10.0)
618
+ separation :
619
+ (Default value = 5.0)
620
+
621
+ Returns
622
+ -------
623
+
624
+ """
625
+ raise RuntimeError("Currently just copied from Sliders, Not actually real")
626
+ with undoContext(self.DCC):
627
+ pos, neg = [], []
628
+ for pp in sorted(self.prog.pairs):
629
+ if pp.value < 0.0:
630
+ neg.append((pp.value, pp.shape, offset))
631
+ offset += separation
632
+ elif pp.value > 0.0:
633
+ pos.append((pp.value, pp.shape, offset))
634
+ offset += separation
635
+ # skip the rest value at == 0.0
636
+ neg = reversed(neg)
637
+
638
+ for prog in [pos, neg]:
639
+ xtVal, shape, shift = prog[-1]
640
+ ext, deltaShape = self.DCC.extractWithDeltaShape(shape, live, shift)
641
+ for value, shape, shift in prog[:-1]:
642
+ self.DCC.extractWithDeltaConnection(
643
+ shape, deltaShape, value / xtVal, live, shift
644
+ )
645
+
646
+ def extractShape(self, shape, live=True, offset=10.0):
647
+ """Extract a shape from a combo progression
648
+
649
+ Parameters
650
+ ----------
651
+ shape : Shape
652
+ The Shape object to extract as a mesh
653
+ live : bool
654
+ Whether to maintain a live connection to the extracted mesh in the DCC (Default value = True)
655
+ offset : float
656
+ The offset to give the extracted mesh in the DCC (Default value = 10.0)
657
+
658
+ Returns
659
+ -------
660
+ : object
661
+ The DCC mesh just created
662
+
663
+ """
664
+ return self.DCC.extractComboShape(self, shape, live, offset)
665
+
666
+ def connectShape(self, shape, mesh=None, live=False, delete=False):
667
+ """Connect a shape into a combo progression
668
+
669
+ Parameters
670
+ ----------
671
+ shape : Shape
672
+ The shape to connect the mesh to
673
+ mesh : object or None
674
+ A DCC mesh to connect into a Shape
675
+ If None, tries to connect by name (Default value = None)
676
+ live : bool
677
+ Whether to maintain a live connecto to the mesh in the DCC (Default value = False)
678
+ delete : bool
679
+ Whether to delete the DCC mesh after it was connected (Default value = False)
680
+
681
+ Returns
682
+ -------
683
+
684
+ """
685
+ self.DCC.connectComboShape(self, shape, mesh, live, delete)
686
+
687
+ @stackable
688
+ def delete(self):
689
+ """Delete this combo and any shapes it contains"""
690
+ self.simplex.deleteDownstream(self)
691
+ mgrs = [model.removeItemManager(self) for model in self.models]
692
+ with nested(*mgrs):
693
+ g = self.group
694
+ if self not in g.items:
695
+ return # Can happen when deleting multiple groups
696
+ g.items.remove(self)
697
+ self.group = None
698
+ self.simplex.combos.remove(self)
699
+ pairs = self.prog.pairs[:] # gotta make a copy
700
+ for pp in pairs:
701
+ if not pp.shape.isRest:
702
+ self.simplex.shapes.remove(pp.shape)
703
+ self.DCC.deleteShape(pp.shape)
704
+
705
+ @stackable
706
+ def setInterpolation(self, interp):
707
+ """Set the interpolation of a combo
708
+
709
+ Parameters
710
+ ----------
711
+ interp : str
712
+ The interpolation for this combo's progression
713
+
714
+ Returns
715
+ -------
716
+
717
+ """
718
+ self.prog.interp = interp
719
+ for model in self.models:
720
+ model.itemDataChanged(self)
721
+
722
+ @stackable
723
+ def setComboValue(self, slider, value):
724
+ """Set the Slider/value pairs for a combo
725
+
726
+ Parameters
727
+ ----------
728
+ slider : Slider
729
+ The slider to set the value for
730
+ value : float
731
+ The value to set the Slider to
732
+
733
+ Returns
734
+ -------
735
+
736
+ """
737
+ idx = self.getSliderIndex(slider)
738
+ pair = self.pairs[idx]
739
+ pair.value = value
740
+ for model in self.models:
741
+ model.itemDataChanged(pair)
742
+
743
+ @stackable
744
+ def appendComboValue(self, slider, value):
745
+ """Append a Slider/value pair for a combo
746
+
747
+ Parameters
748
+ ----------
749
+ slider : Slider
750
+ The slider to insert
751
+ value : float
752
+ The value to set the Slider to
753
+
754
+ Returns
755
+ -------
756
+
757
+ """
758
+ cp = ComboPair(slider, value)
759
+ mgrs = [model.insertItemManager(self) for model in self.models]
760
+ with nested(*mgrs):
761
+ self.pairs.append(cp)
762
+ cp.combo = self
763
+
764
+ @stackable
765
+ def deleteComboPair(self, comboPair):
766
+ """Delete a Slider/value pair for a combo
767
+
768
+ Parameters
769
+ ----------
770
+ comboPair : ComboPair
771
+ The ComboPair to delete
772
+
773
+ Returns
774
+ -------
775
+
776
+ """
777
+ mgrs = [model.removeItemManager(comboPair) for model in self.models]
778
+ with nested(*mgrs):
779
+ # We specifically don't move the combo to the proper depth group
780
+ # That way the user can make multiple changes to the combo without
781
+ # it popping all over in the heirarchy
782
+ self.pairs.remove(comboPair)
783
+ comboPair.combo = None
784
+
785
+ @stackable
786
+ def setGroup(self, grp):
787
+ """Set the group for this Combo
788
+
789
+ Parameters
790
+ ----------
791
+ grp : Group
792
+ The group to set
793
+
794
+ Returns
795
+ -------
796
+
797
+ """
798
+ if grp.groupType is None:
799
+ grp.groupType = type(self)
800
+
801
+ if not isinstance(self, grp.groupType):
802
+ raise ValueError(
803
+ "All items in this group must be of type: {}".format(grp.groupType)
804
+ )
805
+
806
+ mgrs = [model.moveItemManager(self, grp) for model in self.models]
807
+ with nested(*mgrs):
808
+ if self.group:
809
+ self.group.items.remove(self)
810
+ grp.items.append(self)
811
+ self.group = grp
812
+
813
+ @stackable
814
+ def createShape(self, shapeName=None, tVal=None):
815
+ """Create a shape and add it to a progression
816
+
817
+ Parameters
818
+ ----------
819
+ shapeName : str or None
820
+ The name of the shape to create.
821
+ If None, give it a default name
822
+ tVal : float or None
823
+ The progression value to set for the new Shape.
824
+ If None, it gets a "smart" default value
825
+
826
+ Returns
827
+ -------
828
+
829
+ """
830
+ pp, idx = self.prog.newProgPair(shapeName, tVal)
831
+ mgrs = [model.insertItemManager(self.prog, idx) for model in self.models]
832
+ with nested(*mgrs):
833
+ pp.prog = self.prog
834
+ self.prog.pairs.insert(idx, pp)
835
+ return pp
836
+
837
+ def getInputVector(self):
838
+ """Get the input to the Solver that would fully activate this Combo
839
+
840
+ Parameters
841
+ ----------
842
+
843
+ Returns
844
+ -------
845
+ : [float, ...]
846
+ The ordered slider values
847
+
848
+ """
849
+ inVec = [0.0] * len(self.simplex.sliders)
850
+ for cp in self.pairs:
851
+ inVec[self.simplex.sliders.index(cp.slider)] = cp.value
852
+ return inVec