simplex-solver 3.0.18__37-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.
- pysimplex.pyd +0 -0
- simplex_solver-3.0.18.dist-info/METADATA +87 -0
- simplex_solver-3.0.18.dist-info/RECORD +81 -0
- simplex_solver-3.0.18.dist-info/WHEEL +5 -0
- simplex_solver-3.0.18.dist-info/licenses/LICENSE +165 -0
- simplexui/__init__.py +54 -0
- simplexui/channelBox.py +862 -0
- simplexui/comboCheckDialog.py +335 -0
- simplexui/commands/__init__.py +16 -0
- simplexui/commands/alembicCommon.py +1045 -0
- simplexui/commands/applyCorrectives.py +455 -0
- simplexui/commands/buildIceXML.py +443 -0
- simplexui/commands/correctiveInterface.py +271 -0
- simplexui/commands/expandedExport.py +435 -0
- simplexui/commands/hdf5Convert.py +62 -0
- simplexui/commands/mayaCorrectiveInterface.py +164 -0
- simplexui/commands/mesh.py +1086 -0
- simplexui/commands/reorderSimplexPoints.py +103 -0
- simplexui/commands/rigidAlign.py +103 -0
- simplexui/commands/setDelta.xsicompound +60 -0
- simplexui/commands/smpxBlend.py +634 -0
- simplexui/commands/unsubdivide.py +1232 -0
- simplexui/commands/uvTransfer.py +986 -0
- simplexui/commands/xsiCorrectiveInterface.py +136 -0
- simplexui/dragFilter.py +299 -0
- simplexui/falloffDialog.py +476 -0
- simplexui/img/ChefHead.png +0 -0
- simplexui/img/frozen.png +0 -0
- simplexui/interface/__init__.py +30 -0
- simplexui/interface/dummyInterface.py +1564 -0
- simplexui/interface/mayaInterface.py +3197 -0
- simplexui/interface/xsiInterface.py +2944 -0
- simplexui/interfaceModel.py +1040 -0
- simplexui/interfaceModelTrees.py +439 -0
- simplexui/interfaceModel_Test.py +259 -0
- simplexui/items/__init__.py +26 -0
- simplexui/items/accessor.py +217 -0
- simplexui/items/combo.py +855 -0
- simplexui/items/falloff.py +780 -0
- simplexui/items/group.py +295 -0
- simplexui/items/progression.py +745 -0
- simplexui/items/shape.py +444 -0
- simplexui/items/simplex.py +1747 -0
- simplexui/items/slider.py +741 -0
- simplexui/items/stack.py +156 -0
- simplexui/items/traversal.py +969 -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 +260 -0
- simplexui/menu/genericPlugins/checkPossibleCombos.py +47 -0
- simplexui/menu/genericPlugins/exportSplit.py +61 -0
- simplexui/menu/genericPlugins/showFalloffs.py +24 -0
- simplexui/menu/genericPlugins/showTraversals.py +24 -0
- simplexui/menu/genericPlugins/simplexUvTransfer.py +109 -0
- simplexui/menu/genericPlugins/unsubdivide.py +71 -0
- simplexui/menu/mayaPlugins/__init__.py +16 -0
- simplexui/menu/mayaPlugins/exportOther.py +45 -0
- simplexui/menu/mayaPlugins/extractProgressives.py +67 -0
- simplexui/menu/mayaPlugins/freezeCombo.py +251 -0
- simplexui/menu/mayaPlugins/generateShapeIncrementals.py +100 -0
- simplexui/menu/mayaPlugins/importObjs.py +196 -0
- simplexui/menu/mayaPlugins/linearizeTraversal.py +49 -0
- simplexui/menu/mayaPlugins/makeShelfBtn.py +69 -0
- simplexui/menu/mayaPlugins/relaxToSelection.py +77 -0
- simplexui/menu/mayaPlugins/reloadDefinition.py +34 -0
- simplexui/menu/mayaPlugins/snapToNeutral.py +74 -0
- simplexui/menu/mayaPlugins/softSelectToCluster.py +204 -0
- simplexui/menu/mayaPlugins/tweakMix.py +138 -0
- simplexui/menu/mayaPlugins/updateRestShape.py +107 -0
- simplexui/menu/xsiPlugins/__init__.py +16 -0
- simplexui/simplexDialog.py +1391 -0
- simplexui/travCheckDialog.py +393 -0
- simplexui/traversalDialog.py +277 -0
- simplexui/ui/comboCheckDialog.ui +475 -0
- simplexui/ui/falloffDialog.ui +243 -0
- simplexui/ui/simplexDialog.ui +1458 -0
- simplexui/ui/travCheckDialog.ui +488 -0
- simplexui/ui/traversalDialog.ui +532 -0
- simplexui/utils.py +320 -0
|
@@ -0,0 +1,1391 @@
|
|
|
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
|
+
|
|
19
|
+
# Ignore a bunch of linter warnings that show up because of my choice of abstraction
|
|
20
|
+
# pylint: disable=unused-argument,too-many-public-methods,relative-import
|
|
21
|
+
# pylint: disable=too-many-statements,no-self-use,missing-docstring
|
|
22
|
+
from __future__ import absolute_import
|
|
23
|
+
|
|
24
|
+
import json
|
|
25
|
+
import os
|
|
26
|
+
import re
|
|
27
|
+
import sys
|
|
28
|
+
import weakref
|
|
29
|
+
from contextlib import contextmanager
|
|
30
|
+
|
|
31
|
+
import six
|
|
32
|
+
from six.moves import range, zip
|
|
33
|
+
|
|
34
|
+
from .comboCheckDialog import ComboCheckDialog
|
|
35
|
+
from .falloffDialog import FalloffDialog
|
|
36
|
+
from .interface import DCC
|
|
37
|
+
from .interfaceModel import (
|
|
38
|
+
ComboFilterModel,
|
|
39
|
+
ComboModel,
|
|
40
|
+
SimplexModel,
|
|
41
|
+
SliderFilterModel,
|
|
42
|
+
SliderModel,
|
|
43
|
+
coerceIndexToChildType,
|
|
44
|
+
coerceIndexToParentType,
|
|
45
|
+
coerceIndexToRoots,
|
|
46
|
+
)
|
|
47
|
+
from .interfaceModelTrees import ComboTree, SliderTree
|
|
48
|
+
from .items import Combo, Group, ProgPair, Simplex, Slider, Stack
|
|
49
|
+
from .menu import buildToolMenu, loadPlugins
|
|
50
|
+
|
|
51
|
+
# This module imports QT from PyQt4, PySide or PySide2
|
|
52
|
+
# Depending on what's available
|
|
53
|
+
from Qt import QtCompat
|
|
54
|
+
from Qt.QtCore import Qt, Signal
|
|
55
|
+
from Qt.QtGui import QStandardItemModel
|
|
56
|
+
from Qt.QtWidgets import QApplication, QInputDialog, QMessageBox, QProgressDialog
|
|
57
|
+
from .traversalDialog import TraversalDialog
|
|
58
|
+
from .utils import getNextName, getUiFile, makeUnique, naturalSortKey, Prefs
|
|
59
|
+
|
|
60
|
+
if os.environ.get("SIMPLEX_AT_BLUR") == "true":
|
|
61
|
+
# If we're at blur, use our main window subclass
|
|
62
|
+
from blurdev.gui import Window
|
|
63
|
+
else:
|
|
64
|
+
from Qt.QtWidgets import QMainWindow as Window
|
|
65
|
+
|
|
66
|
+
NAME_CHECK = re.compile(r"[A-Za-z][\w.]*")
|
|
67
|
+
|
|
68
|
+
# If the decorated method is a slot for some Qt Signal
|
|
69
|
+
# and the method signature is *NOT* the same as the
|
|
70
|
+
# signal signature, you must double decorate the method like:
|
|
71
|
+
#
|
|
72
|
+
# @Slot(**signature)
|
|
73
|
+
# @stackable
|
|
74
|
+
# def method(**signature)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
@contextmanager
|
|
78
|
+
def signalsBlocked(item):
|
|
79
|
+
"""Context manager to block the qt signals on an item"""
|
|
80
|
+
item.blockSignals(True)
|
|
81
|
+
try:
|
|
82
|
+
yield
|
|
83
|
+
finally:
|
|
84
|
+
item.blockSignals(False)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class SimplexDialog(Window):
|
|
88
|
+
"""The main ui for simplex
|
|
89
|
+
|
|
90
|
+
Parameters
|
|
91
|
+
----------
|
|
92
|
+
parent : QWidget
|
|
93
|
+
The parent for this window
|
|
94
|
+
dispatch : Dispatch
|
|
95
|
+
An object that translates DCC events into
|
|
96
|
+
Qt Signals that the Simplex Ui can understand
|
|
97
|
+
|
|
98
|
+
"""
|
|
99
|
+
|
|
100
|
+
simplexLoaded = Signal()
|
|
101
|
+
openedDialogs = []
|
|
102
|
+
|
|
103
|
+
def __init__(self, parent=None, dispatch=None):
|
|
104
|
+
super(SimplexDialog, self).__init__(parent)
|
|
105
|
+
|
|
106
|
+
uiPath = getUiFile(__file__)
|
|
107
|
+
QtCompat.loadUi(uiPath, self)
|
|
108
|
+
|
|
109
|
+
# Custom widgets aren't working properly, so I bring them in manually
|
|
110
|
+
self.uiSliderTREE = SliderTree(self.uiMainShapesGRP)
|
|
111
|
+
self.uiSliderTREE.setDragEnabled(False)
|
|
112
|
+
self.uiSliderTREE.setDragDropMode(SliderTree.NoDragDrop)
|
|
113
|
+
self.uiSliderTREE.setSelectionMode(SliderTree.ExtendedSelection)
|
|
114
|
+
self.uiSliderTREE.dragFilter.dragPressed.connect(self.dragStart)
|
|
115
|
+
self.uiSliderTREE.dragFilter.dragReleased.connect(self.dragStop)
|
|
116
|
+
|
|
117
|
+
self.uiSliderLAY.addWidget(self.uiSliderTREE)
|
|
118
|
+
|
|
119
|
+
self.uiComboTREE = ComboTree(self.uiComboShapesGRP)
|
|
120
|
+
self.uiComboTREE.setDragEnabled(False)
|
|
121
|
+
self.uiComboTREE.setDragDropMode(ComboTree.NoDragDrop)
|
|
122
|
+
self.uiComboTREE.setSelectionMode(ComboTree.ExtendedSelection)
|
|
123
|
+
self.uiComboTREE.dragFilter.dragPressed.connect(self.dragStart)
|
|
124
|
+
self.uiComboTREE.dragFilter.dragReleased.connect(self.dragStop)
|
|
125
|
+
self.uiComboLAY.addWidget(self.uiComboTREE)
|
|
126
|
+
|
|
127
|
+
self._sliderMenu = None
|
|
128
|
+
self._comboMenu = None
|
|
129
|
+
self._currentObject = None
|
|
130
|
+
self._currentObjectName = None
|
|
131
|
+
|
|
132
|
+
# Connect the combo boxes and spinners to the data model
|
|
133
|
+
# TODO: Figure out how to deal with the type/axis "enum" cboxes
|
|
134
|
+
# see: http://doc.qt.io/qt-5/qtwidgets-itemviews-combowidgetmapper-example.html
|
|
135
|
+
"""
|
|
136
|
+
self._falloffMapper = QDataWidgetMapper()
|
|
137
|
+
self.uiShapeFalloffCBOX.currentIndexChanged.connect(self._falloffMapper.setCurrentIndex)
|
|
138
|
+
"""
|
|
139
|
+
|
|
140
|
+
# Make sure to connect the dispatcher to the undo control
|
|
141
|
+
# but only keep a weakref to it
|
|
142
|
+
self.dispatch = None
|
|
143
|
+
if dispatch is not None:
|
|
144
|
+
self.dispatch = weakref.ref(dispatch)
|
|
145
|
+
dispatch.undo.connect(self.handleUndo)
|
|
146
|
+
dispatch.redo.connect(self.handleUndo)
|
|
147
|
+
dispatch.beforeNew.connect(self.newScene)
|
|
148
|
+
dispatch.beforeOpen.connect(self.newScene)
|
|
149
|
+
|
|
150
|
+
self.simplex = None
|
|
151
|
+
|
|
152
|
+
self._itemMap = {}
|
|
153
|
+
self._sliderTreeMap = {}
|
|
154
|
+
self._comboTreeMap = {}
|
|
155
|
+
|
|
156
|
+
self._sliderDrag = None
|
|
157
|
+
self._comboDrag = None
|
|
158
|
+
|
|
159
|
+
self.uiSliderExitIsolateBTN.hide()
|
|
160
|
+
self.uiComboExitIsolateBTN.hide()
|
|
161
|
+
|
|
162
|
+
self._makeConnections()
|
|
163
|
+
|
|
164
|
+
self._toolPlugins, self._contextPlugins = loadPlugins()
|
|
165
|
+
buildToolMenu(self, self._toolPlugins)
|
|
166
|
+
self.uiSliderTREE.setPlugins(self._contextPlugins)
|
|
167
|
+
self.uiComboTREE.setPlugins(self._contextPlugins)
|
|
168
|
+
|
|
169
|
+
if DCC.program == "dummy":
|
|
170
|
+
# self.getSelectedObject()
|
|
171
|
+
self.uiObjectGRP.setEnabled(False)
|
|
172
|
+
self.uiSystemGRP.setEnabled(False)
|
|
173
|
+
|
|
174
|
+
self.uiClearSelectedObjectBTN.hide()
|
|
175
|
+
self.uiMainShapesGRP.setEnabled(False)
|
|
176
|
+
self.uiComboShapesGRP.setEnabled(False)
|
|
177
|
+
self.uiConnectionGroupWID.setEnabled(False)
|
|
178
|
+
self.loadSettings()
|
|
179
|
+
self._sliderMul = 2.0 if self.uiDoubleSliderRangeACT.isChecked() else 1.0
|
|
180
|
+
|
|
181
|
+
self.travDialog = TraversalDialog(self)
|
|
182
|
+
self.falloffDialog = FalloffDialog(self)
|
|
183
|
+
# self.showTraversalDialog()
|
|
184
|
+
type(self).openedDialogs.append(weakref.ref(self))
|
|
185
|
+
|
|
186
|
+
@classmethod
|
|
187
|
+
def lastOpenedDialog(cls):
|
|
188
|
+
"""Returns the last currently opened dialog that still exists"""
|
|
189
|
+
for dlgRef in reversed(cls.openedDialogs):
|
|
190
|
+
dlg = dlgRef()
|
|
191
|
+
if dlg is not None:
|
|
192
|
+
return dlg
|
|
193
|
+
return None
|
|
194
|
+
|
|
195
|
+
def showTraversalDialog(self):
|
|
196
|
+
"""Display the traversal dialog"""
|
|
197
|
+
self.travDialog.show()
|
|
198
|
+
self.travDialog.setGeometry(30, 30, 400, 400)
|
|
199
|
+
|
|
200
|
+
def showFalloffDialog(self):
|
|
201
|
+
"""Display the Falloff Dialog"""
|
|
202
|
+
self.falloffDialog.show()
|
|
203
|
+
pp = self.falloffDialog.pos()
|
|
204
|
+
x, y = pp.x(), pp.y()
|
|
205
|
+
if x < 0 or y < 0:
|
|
206
|
+
self.falloffDialog.move(max(x, 0), max(y, 0))
|
|
207
|
+
|
|
208
|
+
def dragStart(self):
|
|
209
|
+
"""Slot for handling the start of a MMB Drag event"""
|
|
210
|
+
if self.simplex is not None:
|
|
211
|
+
self.simplex.DCC.undoOpen()
|
|
212
|
+
|
|
213
|
+
def dragStop(self):
|
|
214
|
+
"""Slot for handling the end of a MMB Drag event"""
|
|
215
|
+
if self.simplex is not None:
|
|
216
|
+
self.simplex.DCC.undoClose()
|
|
217
|
+
|
|
218
|
+
def storeSettings(self):
|
|
219
|
+
"""Store the state of the UI for the next run"""
|
|
220
|
+
pref = Prefs()
|
|
221
|
+
pref.recordProperty("geometry", self.saveGeometry())
|
|
222
|
+
pref.save()
|
|
223
|
+
|
|
224
|
+
def loadSettings(self):
|
|
225
|
+
"""Load the state of the UI from a previous run"""
|
|
226
|
+
pref = Prefs()
|
|
227
|
+
geo = pref.restoreProperty("geometry", None)
|
|
228
|
+
if geo is not None:
|
|
229
|
+
self.restoreGeometry(geo)
|
|
230
|
+
|
|
231
|
+
def closeEvent(self, event):
|
|
232
|
+
"""Handle the close event"""
|
|
233
|
+
self.storeSettings()
|
|
234
|
+
self.deleteLater()
|
|
235
|
+
|
|
236
|
+
# Undo/Redo
|
|
237
|
+
def newScene(self):
|
|
238
|
+
"""Call this before a new scene is created. Usually called from the stack"""
|
|
239
|
+
self.clearSelectedObject()
|
|
240
|
+
|
|
241
|
+
def handleUndo(self):
|
|
242
|
+
"""Call this after an undo/redo action. Usually called from the stack"""
|
|
243
|
+
rev = self.simplex.DCC.getRevision()
|
|
244
|
+
data = self.simplex.stack.getRevision(rev)
|
|
245
|
+
if data is not None:
|
|
246
|
+
self.setSystem(data)
|
|
247
|
+
self.uiSliderTREE.setItemExpansion()
|
|
248
|
+
self.uiComboTREE.setItemExpansion()
|
|
249
|
+
|
|
250
|
+
def currentSystemChanged(self, idx):
|
|
251
|
+
"""Slot called when the current system changes"""
|
|
252
|
+
if idx == -1:
|
|
253
|
+
self.setSystem(None)
|
|
254
|
+
return
|
|
255
|
+
name = str(self.uiCurrentSystemCBOX.currentText())
|
|
256
|
+
if not name:
|
|
257
|
+
self.setSystem(None)
|
|
258
|
+
return
|
|
259
|
+
if self.simplex is not None:
|
|
260
|
+
if self.simplex.name == name:
|
|
261
|
+
return # Do nothing
|
|
262
|
+
|
|
263
|
+
pBar = QProgressDialog("Loading from Mesh", "Cancel", 0, 100, self)
|
|
264
|
+
system = Simplex.buildSystemFromMesh(
|
|
265
|
+
self._currentObject, name, sliderMul=self._sliderMul, pBar=pBar
|
|
266
|
+
)
|
|
267
|
+
self.setSystem(system)
|
|
268
|
+
pBar.close()
|
|
269
|
+
|
|
270
|
+
def setSystem(self, system):
|
|
271
|
+
"""Set the system on this UI
|
|
272
|
+
|
|
273
|
+
Parameters
|
|
274
|
+
----------
|
|
275
|
+
system : Simplex
|
|
276
|
+
The Simplex system to load into this UI
|
|
277
|
+
"""
|
|
278
|
+
if system == self.simplex:
|
|
279
|
+
return
|
|
280
|
+
|
|
281
|
+
if self.simplex is not None:
|
|
282
|
+
# disconnect the previous stuff
|
|
283
|
+
sliderSelModel = self.uiSliderTREE.selectionModel()
|
|
284
|
+
sliderSelModel.selectionChanged.disconnect(self.unifySliderSelection)
|
|
285
|
+
sliderSelModel.selectionChanged.disconnect(self.populateComboRequirements)
|
|
286
|
+
sliderSelModel.selectionChanged.disconnect(self.autoSetSliders)
|
|
287
|
+
|
|
288
|
+
comboSelModel = self.uiComboTREE.selectionModel()
|
|
289
|
+
comboSelModel.selectionChanged.disconnect(self.unifyComboSelection)
|
|
290
|
+
comboSelModel.selectionChanged.disconnect(self.populateSliderRequirements)
|
|
291
|
+
comboSelModel.selectionChanged.disconnect(self.autoSetComboSliders)
|
|
292
|
+
|
|
293
|
+
oldStack = self.simplex.stack
|
|
294
|
+
else:
|
|
295
|
+
oldStack = Stack()
|
|
296
|
+
|
|
297
|
+
if system is None:
|
|
298
|
+
# self.toolActions.simplex = None
|
|
299
|
+
self.uiSliderTREE.setModel(QStandardItemModel())
|
|
300
|
+
self.uiComboTREE.setModel(QStandardItemModel())
|
|
301
|
+
self.simplex = system
|
|
302
|
+
self.uiMainShapesGRP.setEnabled(False)
|
|
303
|
+
self.uiComboShapesGRP.setEnabled(False)
|
|
304
|
+
self.uiConnectionGroupWID.setEnabled(False)
|
|
305
|
+
self.falloffDialog.loadSimplex()
|
|
306
|
+
self.simplexLoaded.emit()
|
|
307
|
+
return
|
|
308
|
+
|
|
309
|
+
# set and connect the new stuff
|
|
310
|
+
self.simplex = system
|
|
311
|
+
self.simplex.models = []
|
|
312
|
+
self.simplex.falloffModels = []
|
|
313
|
+
self.simplex.stack = oldStack
|
|
314
|
+
|
|
315
|
+
# self.toolActions.simplex = self.simplex
|
|
316
|
+
|
|
317
|
+
simplexModel = SimplexModel(self.simplex, None)
|
|
318
|
+
|
|
319
|
+
sliderModel = SliderModel(simplexModel, None)
|
|
320
|
+
sliderProxModel = SliderFilterModel(sliderModel)
|
|
321
|
+
self.uiSliderTREE.setModel(sliderProxModel)
|
|
322
|
+
sliderSelModel = self.uiSliderTREE.selectionModel()
|
|
323
|
+
sliderSelModel.selectionChanged.connect(self.unifySliderSelection)
|
|
324
|
+
sliderSelModel.selectionChanged.connect(self.populateComboRequirements)
|
|
325
|
+
sliderSelModel.selectionChanged.connect(self.autoSetSliders)
|
|
326
|
+
|
|
327
|
+
comboModel = ComboModel(simplexModel, None)
|
|
328
|
+
comboProxModel = ComboFilterModel(comboModel)
|
|
329
|
+
self.uiComboTREE.setModel(comboProxModel)
|
|
330
|
+
comboSelModel = self.uiComboTREE.selectionModel()
|
|
331
|
+
comboSelModel.selectionChanged.connect(self.unifyComboSelection)
|
|
332
|
+
comboSelModel.selectionChanged.connect(self.populateSliderRequirements)
|
|
333
|
+
comboSelModel.selectionChanged.connect(self.autoSetComboSliders)
|
|
334
|
+
|
|
335
|
+
self.falloffDialog.loadSimplex()
|
|
336
|
+
|
|
337
|
+
# Make sure the UI is up and running
|
|
338
|
+
self.enableComboRequirements()
|
|
339
|
+
self.enableSliderRequirements()
|
|
340
|
+
self.uiMainShapesGRP.setEnabled(True)
|
|
341
|
+
self.uiComboShapesGRP.setEnabled(True)
|
|
342
|
+
self.uiConnectionGroupWID.setEnabled(True)
|
|
343
|
+
|
|
344
|
+
self.setSimplexLegacy()
|
|
345
|
+
self.simplexLoaded.emit()
|
|
346
|
+
|
|
347
|
+
# UI Setup
|
|
348
|
+
def _makeConnections(self):
|
|
349
|
+
"""Make all the ui connections"""
|
|
350
|
+
# Setup Trees!
|
|
351
|
+
self.uiSliderTREE.setColumnWidth(1, 50)
|
|
352
|
+
self.uiSliderTREE.setColumnWidth(2, 20)
|
|
353
|
+
self.uiSliderFilterLINE.textChanged.connect(self.sliderStringFilter)
|
|
354
|
+
self.uiSliderFilterClearBTN.clicked.connect(self.uiSliderFilterLINE.clear)
|
|
355
|
+
self.uiSliderFilterClearBTN.clicked.connect(self.sliderStringFilter)
|
|
356
|
+
|
|
357
|
+
self.uiComboTREE.setColumnWidth(1, 50)
|
|
358
|
+
self.uiComboTREE.setColumnWidth(2, 20)
|
|
359
|
+
self.uiComboFilterLINE.textChanged.connect(self.comboStringFilter)
|
|
360
|
+
self.uiComboFilterClearBTN.clicked.connect(self.uiComboFilterLINE.clear)
|
|
361
|
+
self.uiComboFilterClearBTN.clicked.connect(self.comboStringFilter)
|
|
362
|
+
|
|
363
|
+
# combo dependency filter setup
|
|
364
|
+
self.uiComboDependGRP.toggled.connect(self.enableComboRequirements)
|
|
365
|
+
self.uiComboDependAllRDO.toggled.connect(self.enableComboRequirements)
|
|
366
|
+
self.uiComboDependAnyRDO.toggled.connect(self.enableComboRequirements)
|
|
367
|
+
self.uiComboDependOnlyRDO.toggled.connect(self.enableComboRequirements)
|
|
368
|
+
self.uiComboDependLockCHK.toggled.connect(self.setLockComboRequirement)
|
|
369
|
+
|
|
370
|
+
# slider dependency filter setup
|
|
371
|
+
self.uiSliderDependGRP.toggled.connect(self.enableSliderRequirements)
|
|
372
|
+
self.uiSliderDependAllRDO.toggled.connect(self.enableSliderRequirements)
|
|
373
|
+
self.uiSliderDependAnyRDO.toggled.connect(self.enableSliderRequirements)
|
|
374
|
+
self.uiSliderDependLockCHK.toggled.connect(self.setLockSliderRequirements)
|
|
375
|
+
|
|
376
|
+
# Bottom Left Corner Buttons
|
|
377
|
+
self.uiZeroAllBTN.clicked.connect(self.zeroAllSliders)
|
|
378
|
+
self.uiZeroSelectedBTN.clicked.connect(self.zeroSelectedSliders)
|
|
379
|
+
self.uiSelectCtrlBTN.clicked.connect(self.selectCtrl)
|
|
380
|
+
|
|
381
|
+
# Top Left Corner Buttons
|
|
382
|
+
self.uiNewGroupBTN.clicked.connect(self.newSliderGroup)
|
|
383
|
+
self.uiNewSliderBTN.clicked.connect(self.newSlider)
|
|
384
|
+
self.uiNewShapeBTN.clicked.connect(self.newSliderShape)
|
|
385
|
+
self.uiSliderDeleteBTN.clicked.connect(self.sliderTreeDelete)
|
|
386
|
+
|
|
387
|
+
# Top Right Corner Buttons
|
|
388
|
+
self.uiDeleteComboBTN.clicked.connect(self.comboTreeDelete)
|
|
389
|
+
self.uiNewComboActiveBTN.clicked.connect(self.newActiveCombo)
|
|
390
|
+
self.uiNewComboSelectBTN.clicked.connect(self.newSelectedCombo)
|
|
391
|
+
self.uiNewComboShapeBTN.clicked.connect(self.newComboShape)
|
|
392
|
+
self.uiNewComboGroupBTN.clicked.connect(self.newComboGroup)
|
|
393
|
+
|
|
394
|
+
# Bottom right corner buttons
|
|
395
|
+
self.uiSetSliderValsBTN.clicked.connect(self.setSliderVals)
|
|
396
|
+
self.uiSelectSlidersBTN.clicked.connect(self.selectSliders)
|
|
397
|
+
|
|
398
|
+
# System level
|
|
399
|
+
self.uiCurrentObjectTXT.editingFinished.connect(self.currentObjectChanged)
|
|
400
|
+
self.uiGetSelectedObjectBTN.clicked.connect(self.getSelectedObject)
|
|
401
|
+
self.uiClearSelectedObjectBTN.clicked.connect(self.clearSelectedObject)
|
|
402
|
+
|
|
403
|
+
self.uiNewSystemBTN.clicked.connect(self.newSystem)
|
|
404
|
+
self.uiRenameSystemBTN.clicked.connect(self.renameSystem)
|
|
405
|
+
self.uiCurrentSystemCBOX.currentIndexChanged[int].connect(
|
|
406
|
+
self.currentSystemChanged
|
|
407
|
+
)
|
|
408
|
+
|
|
409
|
+
# Extraction/connection
|
|
410
|
+
self.uiShapeExtractBTN.clicked.connect(self.shapeExtract)
|
|
411
|
+
self.uiShapeConnectBTN.clicked.connect(self.shapeConnect)
|
|
412
|
+
self.uiShapeConnectSceneBTN.clicked.connect(self.shapeConnectScene)
|
|
413
|
+
|
|
414
|
+
# File Menu
|
|
415
|
+
self.uiImportACT.triggered.connect(self.importSystemFromFile)
|
|
416
|
+
self.uiExportACT.triggered.connect(self.exportSystemTemplate)
|
|
417
|
+
|
|
418
|
+
# Edit Menu
|
|
419
|
+
self.uiHideRedundantACT.toggled.connect(self.hideRedundant)
|
|
420
|
+
self.uiDoubleSliderRangeACT.toggled.connect(self.setSliderRange)
|
|
421
|
+
|
|
422
|
+
# Isolation
|
|
423
|
+
self.uiSliderExitIsolateBTN.clicked.connect(self.sliderTreeExitIsolate)
|
|
424
|
+
self.uiComboExitIsolateBTN.clicked.connect(self.comboTreeExitIsolate)
|
|
425
|
+
|
|
426
|
+
self.uiLegacyJsonACT.toggled.connect(self.setSimplexLegacy)
|
|
427
|
+
|
|
428
|
+
# Helpers
|
|
429
|
+
def getSelectedItems(self, tree, typ=None):
|
|
430
|
+
"""Convenience function to get the selected system items
|
|
431
|
+
|
|
432
|
+
Parameters
|
|
433
|
+
----------
|
|
434
|
+
tree : QTreeView
|
|
435
|
+
The tree to get selected items from
|
|
436
|
+
typ : Type
|
|
437
|
+
The type of objects to return
|
|
438
|
+
|
|
439
|
+
Returns
|
|
440
|
+
-------
|
|
441
|
+
[object, ...]
|
|
442
|
+
A list of selected items
|
|
443
|
+
"""
|
|
444
|
+
sel = tree.selectedIndexes()
|
|
445
|
+
sel = [i for i in sel if i.column() == 0]
|
|
446
|
+
model = tree.model()
|
|
447
|
+
items = [model.itemFromIndex(i) for i in sel]
|
|
448
|
+
if typ is not None:
|
|
449
|
+
items = [i for i in items if isinstance(i, typ)]
|
|
450
|
+
return items
|
|
451
|
+
|
|
452
|
+
def getCurrentObject(self):
|
|
453
|
+
"""Convenience function to get the current object loaded into the UI"""
|
|
454
|
+
return self._currentObject
|
|
455
|
+
|
|
456
|
+
# Setup Trees!
|
|
457
|
+
def sliderStringFilter(self):
|
|
458
|
+
"""Set the filter for the slider tree"""
|
|
459
|
+
filterString = str(self.uiSliderFilterLINE.text())
|
|
460
|
+
sliderModel = self.uiSliderTREE.model()
|
|
461
|
+
sliderModel.filterString = str(filterString)
|
|
462
|
+
sliderModel.invalidateFilter()
|
|
463
|
+
|
|
464
|
+
def comboStringFilter(self):
|
|
465
|
+
"""Set the filter for the combo tree"""
|
|
466
|
+
filterString = str(self.uiComboFilterLINE.text())
|
|
467
|
+
comboModel = self.uiComboTREE.model()
|
|
468
|
+
comboModel.filterString = str(filterString)
|
|
469
|
+
comboModel.invalidateFilter()
|
|
470
|
+
|
|
471
|
+
# selection setup
|
|
472
|
+
def unifySliderSelection(self):
|
|
473
|
+
"""Clear the selection of the combo tree when
|
|
474
|
+
an item on the slider tree is selected
|
|
475
|
+
"""
|
|
476
|
+
mods = QApplication.keyboardModifiers()
|
|
477
|
+
if not mods & (Qt.ControlModifier | Qt.ShiftModifier):
|
|
478
|
+
comboSelModel = self.uiComboTREE.selectionModel()
|
|
479
|
+
if not comboSelModel:
|
|
480
|
+
return
|
|
481
|
+
|
|
482
|
+
with signalsBlocked(comboSelModel):
|
|
483
|
+
comboSelModel.clearSelection()
|
|
484
|
+
self.uiComboTREE.viewport().update()
|
|
485
|
+
|
|
486
|
+
def unifyComboSelection(self):
|
|
487
|
+
"""Clear the selection of the slider tree when
|
|
488
|
+
an item on the combo tree is selected
|
|
489
|
+
"""
|
|
490
|
+
mods = QApplication.keyboardModifiers()
|
|
491
|
+
if not mods & (Qt.ControlModifier | Qt.ShiftModifier):
|
|
492
|
+
sliderSelModel = self.uiSliderTREE.selectionModel()
|
|
493
|
+
if not sliderSelModel:
|
|
494
|
+
return
|
|
495
|
+
with signalsBlocked(sliderSelModel):
|
|
496
|
+
sliderSelModel.clearSelection()
|
|
497
|
+
self.uiSliderTREE.viewport().update()
|
|
498
|
+
|
|
499
|
+
# dependency setup
|
|
500
|
+
def setLockComboRequirement(self):
|
|
501
|
+
"""Refresh the combo selection filter with the new filterLock state"""
|
|
502
|
+
comboModel = self.uiComboTREE.model()
|
|
503
|
+
if not comboModel:
|
|
504
|
+
return
|
|
505
|
+
self.populateComboRequirements()
|
|
506
|
+
|
|
507
|
+
def populateComboRequirements(self):
|
|
508
|
+
"""Let the combo tree know the requirements from the slider tree"""
|
|
509
|
+
items = self.uiSliderTREE.getSelectedItems(Slider)
|
|
510
|
+
comboModel = self.uiComboTREE.model()
|
|
511
|
+
locked = self.uiComboDependLockCHK.isChecked()
|
|
512
|
+
if not locked:
|
|
513
|
+
comboModel.requires = items
|
|
514
|
+
if (
|
|
515
|
+
comboModel.filterRequiresAll
|
|
516
|
+
or comboModel.filterRequiresAny
|
|
517
|
+
or comboModel.filterRequiresOnly
|
|
518
|
+
):
|
|
519
|
+
comboModel.invalidateFilter()
|
|
520
|
+
|
|
521
|
+
def enableComboRequirements(self):
|
|
522
|
+
"""Set the requirements for the combo filter model"""
|
|
523
|
+
comboModel = self.uiComboTREE.model()
|
|
524
|
+
if not comboModel:
|
|
525
|
+
return
|
|
526
|
+
depCheck = self.uiComboDependGRP.isChecked()
|
|
527
|
+
comboModel.filterRequiresAll = self.uiComboDependAllRDO.isChecked() and depCheck
|
|
528
|
+
comboModel.filterRequiresAny = self.uiComboDependAnyRDO.isChecked() and depCheck
|
|
529
|
+
comboModel.filterRequiresOnly = self.uiComboDependOnlyRDO.isChecked() and depCheck
|
|
530
|
+
comboModel.invalidateFilter()
|
|
531
|
+
|
|
532
|
+
def populateSliderRequirements(self):
|
|
533
|
+
"""Let the slider tree know the requirements from the combo tree"""
|
|
534
|
+
items = self.uiComboTREE.getSelectedItems(Combo)
|
|
535
|
+
sliderModel = self.uiSliderTREE.model()
|
|
536
|
+
locked = self.uiSliderDependLockCHK.isChecked()
|
|
537
|
+
if not locked:
|
|
538
|
+
sliderModel.requires = items
|
|
539
|
+
if sliderModel.filterRequiresAny or sliderModel.filterRequiresAll:
|
|
540
|
+
sliderModel.invalidateFilter()
|
|
541
|
+
|
|
542
|
+
def setLockSliderRequirements(self):
|
|
543
|
+
"""Refresh the combo selection filter with the new filterLock state"""
|
|
544
|
+
sliderModel = self.uiSliderTREE.model()
|
|
545
|
+
if not sliderModel:
|
|
546
|
+
return
|
|
547
|
+
self.populateSliderRequirements()
|
|
548
|
+
|
|
549
|
+
def enableSliderRequirements(self):
|
|
550
|
+
sliderModel = self.uiSliderTREE.model()
|
|
551
|
+
if not sliderModel:
|
|
552
|
+
return
|
|
553
|
+
|
|
554
|
+
depCheck = self.uiSliderDependGRP.isChecked()
|
|
555
|
+
sliderModel.filterRequiresAny = self.uiSliderDependAnyRDO.isChecked() and depCheck
|
|
556
|
+
sliderModel.filterRequiresAll = self.uiSliderDependAllRDO.isChecked() and depCheck
|
|
557
|
+
sliderModel.invalidateFilter()
|
|
558
|
+
|
|
559
|
+
# Bottom Left Corner Buttons
|
|
560
|
+
def zeroAllSliders(self):
|
|
561
|
+
"""Slot to Zero all Sliders in Slider UI panel"""
|
|
562
|
+
if self.simplex is None:
|
|
563
|
+
return
|
|
564
|
+
sliders = self.simplex.sliders
|
|
565
|
+
weights = [0.0] * len(sliders)
|
|
566
|
+
self.simplex.setSlidersWeights(sliders, weights)
|
|
567
|
+
self.uiSliderTREE.repaint()
|
|
568
|
+
|
|
569
|
+
def zeroSelectedSliders(self):
|
|
570
|
+
"""Slot to Zero the selected sliders in the UI panel"""
|
|
571
|
+
if self.simplex is None:
|
|
572
|
+
return
|
|
573
|
+
items = self.uiSliderTREE.getSelectedItems(Slider)
|
|
574
|
+
values = [0.0] * len(items)
|
|
575
|
+
self.simplex.setSlidersWeights(items, values)
|
|
576
|
+
self.uiSliderTREE.repaint()
|
|
577
|
+
|
|
578
|
+
def selectCtrl(self):
|
|
579
|
+
"""Select the Control object in the DCC"""
|
|
580
|
+
if self.simplex is None:
|
|
581
|
+
return
|
|
582
|
+
self.simplex.DCC.selectCtrl()
|
|
583
|
+
|
|
584
|
+
def autoSetSliders(self):
|
|
585
|
+
"""Automatically set any selected sliders to 1.0"""
|
|
586
|
+
if self.simplex is None:
|
|
587
|
+
return
|
|
588
|
+
if not self.uiAutoSetSlidersCHK.isChecked():
|
|
589
|
+
return
|
|
590
|
+
sel = set(self.uiSliderTREE.getSelectedItems(Slider))
|
|
591
|
+
sliders = self.simplex.sliders
|
|
592
|
+
|
|
593
|
+
weights = [0.0] * len(sliders)
|
|
594
|
+
for i, slider in enumerate(sliders):
|
|
595
|
+
if slider in sel:
|
|
596
|
+
weights[i] = 1.0
|
|
597
|
+
self.simplex.setSlidersWeights(sliders, weights)
|
|
598
|
+
self.uiSliderTREE.repaint()
|
|
599
|
+
|
|
600
|
+
def _getAName(self, tpe, default=None, taken=tuple(), uniqueAccept=False):
|
|
601
|
+
"""uniqueAccept forces the user to provide and accept a unique name
|
|
602
|
+
If the user enters a non-unique name, the name is uniquified, and the
|
|
603
|
+
dialog is re-shown with the unique name as the default suggestion
|
|
604
|
+
"""
|
|
605
|
+
tpe = tpe.lower()
|
|
606
|
+
uTpe = tpe[0].upper() + tpe[1:]
|
|
607
|
+
|
|
608
|
+
unique = False
|
|
609
|
+
default = getNextName(default, taken)
|
|
610
|
+
while not unique:
|
|
611
|
+
eMsg = "Enter a name for the new {0}".format(tpe)
|
|
612
|
+
newName, good = QInputDialog.getText(
|
|
613
|
+
self, "New {0}".format(uTpe), eMsg, text=default
|
|
614
|
+
)
|
|
615
|
+
if not good:
|
|
616
|
+
return None
|
|
617
|
+
if len(newName) < 3:
|
|
618
|
+
message = "Please use names longer than 2 letters"
|
|
619
|
+
QMessageBox.warning(self, "Warning", message)
|
|
620
|
+
return None
|
|
621
|
+
if not NAME_CHECK.match(newName):
|
|
622
|
+
message = "{0} name can only contain letters and numbers, and cannot start with a number"
|
|
623
|
+
message = message.format(uTpe)
|
|
624
|
+
QMessageBox.warning(self, "Warning", message)
|
|
625
|
+
return None
|
|
626
|
+
|
|
627
|
+
unqName = getNextName(newName, taken)
|
|
628
|
+
unique = (unqName == newName) or uniqueAccept
|
|
629
|
+
default = unqName
|
|
630
|
+
|
|
631
|
+
return default
|
|
632
|
+
|
|
633
|
+
# Top Left Corner Buttons
|
|
634
|
+
def newSliderGroup(self):
|
|
635
|
+
"""Slot to Create a new slider group"""
|
|
636
|
+
if self.simplex is None:
|
|
637
|
+
return
|
|
638
|
+
|
|
639
|
+
newName = self._getAName("group", default="Group")
|
|
640
|
+
if newName is None:
|
|
641
|
+
return
|
|
642
|
+
|
|
643
|
+
Group.createGroup(str(newName), self.simplex, groupType=Slider)
|
|
644
|
+
# self.uiSliderTREE.model().invalidateFilter()
|
|
645
|
+
# self.uiComboTREE.model().invalidateFilter()
|
|
646
|
+
|
|
647
|
+
def newSlider(self):
|
|
648
|
+
"""Slot to create a new slider"""
|
|
649
|
+
if self.simplex is None:
|
|
650
|
+
return
|
|
651
|
+
|
|
652
|
+
newName = self._getAName("slider")
|
|
653
|
+
if newName is None:
|
|
654
|
+
return
|
|
655
|
+
|
|
656
|
+
idxs = self.uiSliderTREE.getSelectedIndexes()
|
|
657
|
+
groups = coerceIndexToParentType(idxs, Group)
|
|
658
|
+
group = groups[0].model().itemFromIndex(groups[0]) if groups else None
|
|
659
|
+
|
|
660
|
+
Slider.createSlider(str(newName), self.simplex, group=group)
|
|
661
|
+
|
|
662
|
+
def newSliderShape(self):
|
|
663
|
+
"""Slot to create a new Shape in a Slider's progression"""
|
|
664
|
+
pars = self.uiSliderTREE.getSelectedItems(Slider)
|
|
665
|
+
if not pars:
|
|
666
|
+
return
|
|
667
|
+
parItem = pars[0]
|
|
668
|
+
parItem.createShape()
|
|
669
|
+
self.uiSliderTREE.model().invalidateFilter()
|
|
670
|
+
|
|
671
|
+
def sliderTreeDelete(self):
|
|
672
|
+
"""Delete some objects in the slider tree"""
|
|
673
|
+
idxs = self.uiSliderTREE.getSelectedIndexes()
|
|
674
|
+
roots = coerceIndexToRoots(idxs)
|
|
675
|
+
if not roots:
|
|
676
|
+
QMessageBox.warning(self, "Warning", "Nothing Selected in Slider tree")
|
|
677
|
+
return
|
|
678
|
+
roots = makeUnique([i.model().itemFromIndex(i) for i in roots])
|
|
679
|
+
for r in roots:
|
|
680
|
+
if isinstance(r, Simplex):
|
|
681
|
+
QMessageBox.warning(
|
|
682
|
+
self, "Warning", "Cannot delete a simplex system this way"
|
|
683
|
+
)
|
|
684
|
+
return
|
|
685
|
+
|
|
686
|
+
for r in roots:
|
|
687
|
+
r.delete()
|
|
688
|
+
self.uiSliderTREE.model().invalidateFilter()
|
|
689
|
+
|
|
690
|
+
# Top Right Corner Buttons
|
|
691
|
+
def comboTreeDelete(self):
|
|
692
|
+
"""Delete some objects in the Combo tree"""
|
|
693
|
+
idxs = self.uiComboTREE.getSelectedIndexes()
|
|
694
|
+
roots = coerceIndexToRoots(idxs)
|
|
695
|
+
if not roots:
|
|
696
|
+
QMessageBox.warning(self, "Warning", "Nothing Selected in Combo tree")
|
|
697
|
+
return
|
|
698
|
+
roots = makeUnique([i.model().itemFromIndex(i) for i in roots])
|
|
699
|
+
for r in roots:
|
|
700
|
+
if isinstance(r, Simplex):
|
|
701
|
+
QMessageBox.warning(
|
|
702
|
+
self, "Warning", "Cannot delete a simplex system this way"
|
|
703
|
+
)
|
|
704
|
+
return
|
|
705
|
+
|
|
706
|
+
for r in roots:
|
|
707
|
+
r.delete()
|
|
708
|
+
self.uiComboTREE.model().invalidateFilter()
|
|
709
|
+
|
|
710
|
+
def _newCombo(self, sliders, values):
|
|
711
|
+
if len(sliders) < 2:
|
|
712
|
+
message = "A combo must use at least 2 sliders"
|
|
713
|
+
QMessageBox.warning(self, "Warning", message)
|
|
714
|
+
return
|
|
715
|
+
|
|
716
|
+
ccd = ComboCheckDialog(sliders, values=values, mode="create", parent=self)
|
|
717
|
+
ccd.move(self.pos())
|
|
718
|
+
ccd.exec_()
|
|
719
|
+
|
|
720
|
+
def newActiveCombo(self):
|
|
721
|
+
"""Create a combo based on the UI Sliders that are currently nonzero"""
|
|
722
|
+
if self.simplex is None:
|
|
723
|
+
return
|
|
724
|
+
sliders = []
|
|
725
|
+
values = {}
|
|
726
|
+
for s in self.simplex.sliders:
|
|
727
|
+
if s.value != 0.0:
|
|
728
|
+
sliders.append(s)
|
|
729
|
+
values[s] = [s.value]
|
|
730
|
+
self._newCombo(sliders, values)
|
|
731
|
+
|
|
732
|
+
def newSelectedCombo(self):
|
|
733
|
+
"""Create a combo based on the currently selected UI sliders"""
|
|
734
|
+
if self.simplex is None:
|
|
735
|
+
return
|
|
736
|
+
sliders = self.uiSliderTREE.getSelectedItems(Slider)
|
|
737
|
+
values = {s: [1.0] for s in sliders}
|
|
738
|
+
self._newCombo(sliders, values)
|
|
739
|
+
|
|
740
|
+
def newComboShape(self):
|
|
741
|
+
"""Create a new shape in the Combo's progression"""
|
|
742
|
+
parIdxs = self.uiComboTREE.getSelectedIndexes()
|
|
743
|
+
pars = coerceIndexToParentType(parIdxs, Combo)
|
|
744
|
+
if not pars:
|
|
745
|
+
return
|
|
746
|
+
|
|
747
|
+
parItem = pars[0].model().itemFromIndex(pars[0]) if pars else None
|
|
748
|
+
parItem.createShape()
|
|
749
|
+
self.uiComboTREE.model().invalidateFilter()
|
|
750
|
+
|
|
751
|
+
def newComboGroup(self):
|
|
752
|
+
"""Create a new group for organizing combos"""
|
|
753
|
+
if self.simplex is None:
|
|
754
|
+
return
|
|
755
|
+
|
|
756
|
+
newName = self._getAName("group", default="Group")
|
|
757
|
+
if newName is None:
|
|
758
|
+
return
|
|
759
|
+
|
|
760
|
+
Group.createGroup(str(newName), self.simplex, groupType=Combo)
|
|
761
|
+
# self.uiComboTREE.model().invalidateFilter()
|
|
762
|
+
# self.uiSliderTREE.model().invalidateFilter()
|
|
763
|
+
|
|
764
|
+
# Bottom right corner buttons
|
|
765
|
+
def setSliderVals(self):
|
|
766
|
+
"""Set all slider values to those stored in the currently selected Combos"""
|
|
767
|
+
if self.simplex is None:
|
|
768
|
+
return
|
|
769
|
+
combos = self.uiComboTREE.getSelectedItems(Combo)
|
|
770
|
+
# maybe coerce to type instead??
|
|
771
|
+
self.zeroAllSliders()
|
|
772
|
+
values = []
|
|
773
|
+
sliders = []
|
|
774
|
+
for combo in combos:
|
|
775
|
+
for pair in combo.pairs:
|
|
776
|
+
if pair.slider in sliders:
|
|
777
|
+
continue
|
|
778
|
+
sliders.append(pair.slider)
|
|
779
|
+
values.append(pair.value)
|
|
780
|
+
self.simplex.setSlidersWeights(sliders, values)
|
|
781
|
+
self.uiSliderTREE.repaint()
|
|
782
|
+
|
|
783
|
+
def selectSliders(self):
|
|
784
|
+
"""Select the sliders that are contained in the currently selected Combos"""
|
|
785
|
+
combos = self.uiComboTREE.getSelectedItems(Combo)
|
|
786
|
+
sliders = []
|
|
787
|
+
for combo in combos:
|
|
788
|
+
for pair in combo.pairs:
|
|
789
|
+
sliders.append(pair.slider)
|
|
790
|
+
self.uiSliderTREE.setItemSelection(sliders)
|
|
791
|
+
|
|
792
|
+
def autoSetComboSliders(self):
|
|
793
|
+
"""Automatically set the DCC Slider values to activate the currently selected Combos"""
|
|
794
|
+
if self.simplex is None:
|
|
795
|
+
return
|
|
796
|
+
if not self.uiAutoSetCombosCHK.isChecked():
|
|
797
|
+
return
|
|
798
|
+
sel = set(self.uiComboTREE.getSelectedItems(Combo))
|
|
799
|
+
sv = {}
|
|
800
|
+
for combo in self.simplex.combos:
|
|
801
|
+
isSel = combo in sel
|
|
802
|
+
for pair in combo.pairs:
|
|
803
|
+
curVal = sv.get(pair.slider, 0.0)
|
|
804
|
+
newVal = pair.value if isSel else 0.0
|
|
805
|
+
if abs(newVal) >= abs(curVal):
|
|
806
|
+
sv[pair.slider] = newVal
|
|
807
|
+
|
|
808
|
+
sliders, weights = list(zip(*list(sv.items())))
|
|
809
|
+
self.simplex.setSlidersWeights(sliders, weights)
|
|
810
|
+
self.uiSliderTREE.repaint()
|
|
811
|
+
|
|
812
|
+
# Extraction/connection
|
|
813
|
+
def shapeConnectScene(self):
|
|
814
|
+
"""Connect any selected meshes into the system based on the name"""
|
|
815
|
+
if self.simplex is None:
|
|
816
|
+
return
|
|
817
|
+
# make a dict of name:object
|
|
818
|
+
sel = DCC.getSelectedObjects()
|
|
819
|
+
selDict = {}
|
|
820
|
+
for s in sel:
|
|
821
|
+
name = DCC.getObjectName(s)
|
|
822
|
+
if name.endswith("_Extract"):
|
|
823
|
+
nn = name.rsplit("_Extract", 1)[0]
|
|
824
|
+
selDict[nn] = s
|
|
825
|
+
|
|
826
|
+
pairDict = {}
|
|
827
|
+
for p in self.simplex.progs:
|
|
828
|
+
for pp in p.pairs:
|
|
829
|
+
pairDict[pp.shape.name] = pp
|
|
830
|
+
|
|
831
|
+
# get all common names
|
|
832
|
+
selKeys = set(six.iterkeys(selDict))
|
|
833
|
+
pairKeys = set(six.iterkeys(pairDict))
|
|
834
|
+
common = selKeys & pairKeys
|
|
835
|
+
|
|
836
|
+
# get those items
|
|
837
|
+
pairs = [pairDict[i] for i in common]
|
|
838
|
+
|
|
839
|
+
# Set up the progress bar
|
|
840
|
+
pBar = QProgressDialog("Connecting Shapes", "Cancel", 0, 100, self)
|
|
841
|
+
pBar.setMaximum(len(pairs))
|
|
842
|
+
|
|
843
|
+
# Do the extractions
|
|
844
|
+
for pair in pairs:
|
|
845
|
+
c = pair.prog.controller
|
|
846
|
+
c.connectShape(pair.shape, delete=True)
|
|
847
|
+
|
|
848
|
+
# ProgressBar
|
|
849
|
+
pBar.setValue(pBar.value() + 1)
|
|
850
|
+
pBar.setLabelText("Connecting:\n{0}".format(pair.shape.name))
|
|
851
|
+
QApplication.processEvents()
|
|
852
|
+
if pBar.wasCanceled():
|
|
853
|
+
return
|
|
854
|
+
|
|
855
|
+
pBar.close()
|
|
856
|
+
|
|
857
|
+
def sliderShapeExtract(self):
|
|
858
|
+
"""Create meshes that are possibly live-connected to the shapes"""
|
|
859
|
+
sliderIdxs = self.uiSliderTREE.getSelectedIndexes()
|
|
860
|
+
return self.shapeIndexExtract(sliderIdxs)
|
|
861
|
+
|
|
862
|
+
def comboShapeExtract(self):
|
|
863
|
+
"""Create meshes that are possibly live-connected to the shapes"""
|
|
864
|
+
comboIdxs = self.uiComboTREE.getSelectedIndexes()
|
|
865
|
+
return self.shapeIndexExtract(comboIdxs)
|
|
866
|
+
|
|
867
|
+
def shapeExtract(self):
|
|
868
|
+
"""Create meshes that are possibly live-connected to the shapes"""
|
|
869
|
+
sliderIdxs = self.uiSliderTREE.getSelectedIndexes()
|
|
870
|
+
comboIdxs = self.uiComboTREE.getSelectedIndexes()
|
|
871
|
+
return self.shapeIndexExtract(sliderIdxs + comboIdxs)
|
|
872
|
+
|
|
873
|
+
def shapeIndexExtract(self, indexes, live=None):
|
|
874
|
+
"""Create meshes that are possibly live-connected to the shapes
|
|
875
|
+
|
|
876
|
+
Parameters
|
|
877
|
+
----------
|
|
878
|
+
indexes : [QModelIndex, ...]
|
|
879
|
+
A list of indexes to extract
|
|
880
|
+
live : bool or None
|
|
881
|
+
Whether the connection is live. If None, check the UI properties
|
|
882
|
+
"""
|
|
883
|
+
if live is None:
|
|
884
|
+
live = self.uiLiveShapeConnectionACT.isChecked()
|
|
885
|
+
|
|
886
|
+
pairs = coerceIndexToChildType(indexes, ProgPair)
|
|
887
|
+
pairs = [i.model().itemFromIndex(i) for i in pairs]
|
|
888
|
+
pairs = makeUnique([i for i in pairs if not i.shape.isRest])
|
|
889
|
+
pairs.sort(key=lambda x: naturalSortKey(x.shape.name))
|
|
890
|
+
|
|
891
|
+
# Set up the progress bar
|
|
892
|
+
pBar = QProgressDialog("Extracting Shapes", "Cancel", 0, 100, self)
|
|
893
|
+
pBar.setMaximum(len(pairs))
|
|
894
|
+
|
|
895
|
+
# Do the extractions
|
|
896
|
+
offset = 10
|
|
897
|
+
extracted = []
|
|
898
|
+
for pair in pairs:
|
|
899
|
+
c = pair.prog.controller
|
|
900
|
+
ext = c.extractShape(pair.shape, live=live, offset=offset)
|
|
901
|
+
extracted.append(ext)
|
|
902
|
+
offset += 5
|
|
903
|
+
|
|
904
|
+
# ProgressBar
|
|
905
|
+
pBar.setValue(pBar.value() + 1)
|
|
906
|
+
pBar.setLabelText("Extracting:\n{0}".format(pair.shape.name))
|
|
907
|
+
QApplication.processEvents()
|
|
908
|
+
if pBar.wasCanceled():
|
|
909
|
+
return extracted
|
|
910
|
+
|
|
911
|
+
pBar.close()
|
|
912
|
+
return extracted
|
|
913
|
+
|
|
914
|
+
def shapeConnect(self):
|
|
915
|
+
"""Match any selected Shapes to DCC meshes based on their names, then delete the Meshes"""
|
|
916
|
+
sliderIdxs = self.uiSliderTREE.getSelectedIndexes()
|
|
917
|
+
comboIdxs = self.uiComboTREE.getSelectedIndexes()
|
|
918
|
+
self.shapeConnectIndexes(sliderIdxs + comboIdxs)
|
|
919
|
+
|
|
920
|
+
def shapeConnectIndexes(self, indexes):
|
|
921
|
+
"""Match the provided shapes to DCC meshes based on their names, then delete the Meshes
|
|
922
|
+
|
|
923
|
+
Parameters
|
|
924
|
+
----------
|
|
925
|
+
indexes : list of QModelIndex
|
|
926
|
+
A list of selected model indexes
|
|
927
|
+
"""
|
|
928
|
+
pairs = coerceIndexToChildType(indexes, ProgPair)
|
|
929
|
+
pairs = [i.model().itemFromIndex(i) for i in pairs]
|
|
930
|
+
pairs = makeUnique([i for i in pairs if not i.shape.isRest])
|
|
931
|
+
|
|
932
|
+
# Set up the progress bar
|
|
933
|
+
pBar = QProgressDialog("Connecting Shapes", "Cancel", 0, 100, self)
|
|
934
|
+
pBar.setMaximum(len(pairs))
|
|
935
|
+
|
|
936
|
+
# Do the extractions
|
|
937
|
+
for pair in pairs:
|
|
938
|
+
c = pair.prog.controller
|
|
939
|
+
c.connectShape(pair.shape, delete=True)
|
|
940
|
+
|
|
941
|
+
# ProgressBar
|
|
942
|
+
pBar.setValue(pBar.value() + 1)
|
|
943
|
+
pBar.setLabelText("Extracting:\n{0}".format(pair.shape.name))
|
|
944
|
+
QApplication.processEvents()
|
|
945
|
+
if pBar.wasCanceled():
|
|
946
|
+
return
|
|
947
|
+
|
|
948
|
+
pBar.close()
|
|
949
|
+
|
|
950
|
+
def shapeMatch(self):
|
|
951
|
+
"""Match any selected Shapes to A selected DCC mesh"""
|
|
952
|
+
sliderIdxs = self.uiSliderTREE.getSelectedIndexes()
|
|
953
|
+
comboIdxs = self.uiComboTREE.getSelectedIndexes()
|
|
954
|
+
self.shapeMatchIndexes(sliderIdxs + comboIdxs)
|
|
955
|
+
|
|
956
|
+
def shapeMatchIndexes(self, indexes):
|
|
957
|
+
"""Match any provided shapes to A selected DCC mesh
|
|
958
|
+
|
|
959
|
+
Parameters
|
|
960
|
+
----------
|
|
961
|
+
indexes : list of QModelIndex
|
|
962
|
+
A list of selected model indexes
|
|
963
|
+
"""
|
|
964
|
+
# make a dict of name:object
|
|
965
|
+
sel = DCC.getSelectedObjects()
|
|
966
|
+
if not sel:
|
|
967
|
+
return
|
|
968
|
+
mesh = sel[0]
|
|
969
|
+
|
|
970
|
+
pairs = coerceIndexToChildType(indexes, ProgPair)
|
|
971
|
+
pairs = [i.model().itemFromIndex(i) for i in pairs]
|
|
972
|
+
pairs = makeUnique([i for i in pairs if not i.shape.isRest])
|
|
973
|
+
|
|
974
|
+
# Set up the progress bar
|
|
975
|
+
pBar = QProgressDialog("Matching Shapes", "Cancel", 0, 100, self)
|
|
976
|
+
pBar.setMaximum(len(pairs))
|
|
977
|
+
|
|
978
|
+
# Do the extractions
|
|
979
|
+
for pair in pairs:
|
|
980
|
+
c = pair.prog.controller
|
|
981
|
+
c.connectShape(pair.shape, mesh=mesh)
|
|
982
|
+
|
|
983
|
+
# ProgressBar
|
|
984
|
+
pBar.setValue(pBar.value() + 1)
|
|
985
|
+
pBar.setLabelText("Matching:\n{0}".format(pair.shape.name))
|
|
986
|
+
QApplication.processEvents()
|
|
987
|
+
if pBar.wasCanceled():
|
|
988
|
+
return
|
|
989
|
+
|
|
990
|
+
pBar.close()
|
|
991
|
+
|
|
992
|
+
def shapeClear(self):
|
|
993
|
+
"""Match all selected shapes to the rest"""
|
|
994
|
+
sliderIdxs = self.uiSliderTREE.getSelectedIndexes()
|
|
995
|
+
comboIdxs = self.uiComboTREE.getSelectedIndexes()
|
|
996
|
+
self.shapeClearIndexes(sliderIdxs + comboIdxs)
|
|
997
|
+
|
|
998
|
+
def shapeClearIndexes(self, indexes):
|
|
999
|
+
"""Match all provided shapes to the rest
|
|
1000
|
+
|
|
1001
|
+
Parameters
|
|
1002
|
+
----------
|
|
1003
|
+
indexes : list of QModelIndex
|
|
1004
|
+
A list of selected model indexes
|
|
1005
|
+
"""
|
|
1006
|
+
pairs = coerceIndexToChildType(indexes, ProgPair)
|
|
1007
|
+
pairs = [i.model().itemFromIndex(i) for i in pairs]
|
|
1008
|
+
pairs = makeUnique([i for i in pairs if not i.shape.isRest])
|
|
1009
|
+
|
|
1010
|
+
for pair in pairs:
|
|
1011
|
+
pair.shape.zeroShape()
|
|
1012
|
+
|
|
1013
|
+
# System level
|
|
1014
|
+
def loadObject(self, thing):
|
|
1015
|
+
"""Load a DCC mesh into the UI
|
|
1016
|
+
|
|
1017
|
+
Parameters
|
|
1018
|
+
----------
|
|
1019
|
+
thing : object
|
|
1020
|
+
The DCC mesh to load into the UI
|
|
1021
|
+
"""
|
|
1022
|
+
if thing is None:
|
|
1023
|
+
return
|
|
1024
|
+
|
|
1025
|
+
self.uiClearSelectedObjectBTN.show()
|
|
1026
|
+
self.uiCurrentSystemCBOX.clear()
|
|
1027
|
+
objName = DCC.getObjectName(thing)
|
|
1028
|
+
self._currentObject = thing
|
|
1029
|
+
self._currentObjectName = objName
|
|
1030
|
+
self.uiCurrentObjectTXT.setText(objName)
|
|
1031
|
+
|
|
1032
|
+
ops = DCC.getSimplexOperatorsOnObject(self._currentObject)
|
|
1033
|
+
|
|
1034
|
+
for op in ops:
|
|
1035
|
+
js = DCC.getSimplexString(op)
|
|
1036
|
+
if not js:
|
|
1037
|
+
continue
|
|
1038
|
+
d = json.loads(js)
|
|
1039
|
+
name = d["systemName"]
|
|
1040
|
+
self.uiCurrentSystemCBOX.addItem(name, (self._currentObject, name))
|
|
1041
|
+
|
|
1042
|
+
def currentObjectChanged(self):
|
|
1043
|
+
"""Slot called when the current DCC object is changed"""
|
|
1044
|
+
name = str(self.uiCurrentObjectTXT.text())
|
|
1045
|
+
if self._currentObjectName == name:
|
|
1046
|
+
return
|
|
1047
|
+
if not name:
|
|
1048
|
+
return
|
|
1049
|
+
|
|
1050
|
+
newObject = DCC.getObjectByName(name)
|
|
1051
|
+
if not newObject:
|
|
1052
|
+
return
|
|
1053
|
+
|
|
1054
|
+
self.loadObject(newObject)
|
|
1055
|
+
|
|
1056
|
+
def getSelectedObject(self):
|
|
1057
|
+
"""Load the first selected DCC object into the UI"""
|
|
1058
|
+
sel = DCC.getSelectedObjects()
|
|
1059
|
+
if not sel:
|
|
1060
|
+
return
|
|
1061
|
+
newObj = sel[0]
|
|
1062
|
+
if not newObj:
|
|
1063
|
+
return
|
|
1064
|
+
self.loadObject(newObj)
|
|
1065
|
+
|
|
1066
|
+
def clearSelectedObject(self):
|
|
1067
|
+
"""Unload the current DCC object from the UI"""
|
|
1068
|
+
self.uiClearSelectedObjectBTN.hide()
|
|
1069
|
+
self.uiCurrentSystemCBOX.clear()
|
|
1070
|
+
self._currentObject = None
|
|
1071
|
+
self._currentObjectName = None
|
|
1072
|
+
self.uiCurrentObjectTXT.setText("")
|
|
1073
|
+
self.setSystem(None)
|
|
1074
|
+
# Clear the current system
|
|
1075
|
+
|
|
1076
|
+
def newSystem(self):
|
|
1077
|
+
"""Create a new system on the current DCC Object"""
|
|
1078
|
+
if self._currentObject is None:
|
|
1079
|
+
QMessageBox.warning(self, "Warning", "Must have a current object selection")
|
|
1080
|
+
return
|
|
1081
|
+
|
|
1082
|
+
newName = self._getAName("system")
|
|
1083
|
+
if newName is None:
|
|
1084
|
+
return
|
|
1085
|
+
|
|
1086
|
+
newSystem = Simplex.buildEmptySystem(
|
|
1087
|
+
self._currentObject, newName, sliderMul=self._sliderMul
|
|
1088
|
+
)
|
|
1089
|
+
with signalsBlocked(self.uiCurrentSystemCBOX):
|
|
1090
|
+
self.uiCurrentSystemCBOX.addItem(newName)
|
|
1091
|
+
self.uiCurrentSystemCBOX.setCurrentIndex(
|
|
1092
|
+
self.uiCurrentSystemCBOX.count() - 1
|
|
1093
|
+
)
|
|
1094
|
+
self.setSystem(newSystem)
|
|
1095
|
+
|
|
1096
|
+
def renameSystem(self):
|
|
1097
|
+
"""Rename the current Simplex system"""
|
|
1098
|
+
if self.simplex is None:
|
|
1099
|
+
return
|
|
1100
|
+
|
|
1101
|
+
sysNames = [
|
|
1102
|
+
str(self.uiCurrentSystemCBOX.itemText(i))
|
|
1103
|
+
for i in range(self.uiCurrentSystemCBOX.count())
|
|
1104
|
+
]
|
|
1105
|
+
newName = self._getAName("system", taken=sysNames)
|
|
1106
|
+
if newName is None:
|
|
1107
|
+
return
|
|
1108
|
+
|
|
1109
|
+
self.simplex.name = newName
|
|
1110
|
+
idx = self.uiCurrentSystemCBOX.currentIndex()
|
|
1111
|
+
self.uiCurrentSystemCBOX.setItemText(idx, newName)
|
|
1112
|
+
|
|
1113
|
+
self.currentSystemChanged(idx)
|
|
1114
|
+
|
|
1115
|
+
def setSimplexLegacy(self):
|
|
1116
|
+
"""Slot to toggle the legacy behavior of the current Simplex system"""
|
|
1117
|
+
if self.simplex is not None:
|
|
1118
|
+
self.simplex.setLegacy(self.uiLegacyJsonACT.isChecked())
|
|
1119
|
+
self.simplex.DCC.incrementRevision()
|
|
1120
|
+
|
|
1121
|
+
# File Menu
|
|
1122
|
+
def importSystemFromFile(self):
|
|
1123
|
+
"""Open a File Dialog to load a simplex system from a file.
|
|
1124
|
+
Systems can be in either .smpx, or .json formats
|
|
1125
|
+
"""
|
|
1126
|
+
if self._currentObject is None:
|
|
1127
|
+
impTypes = ["smpx"]
|
|
1128
|
+
else:
|
|
1129
|
+
impTypes = ["smpx", "json"]
|
|
1130
|
+
|
|
1131
|
+
pref = Prefs()
|
|
1132
|
+
defaultPath = str(
|
|
1133
|
+
pref.restoreProperty(
|
|
1134
|
+
"systemImport", os.path.join(os.path.expanduser("~"))
|
|
1135
|
+
)
|
|
1136
|
+
)
|
|
1137
|
+
path = self._fileDialog(
|
|
1138
|
+
"Import Template", defaultPath, impTypes, save=False
|
|
1139
|
+
)
|
|
1140
|
+
if not path:
|
|
1141
|
+
return
|
|
1142
|
+
pref.recordProperty("systemImport", os.path.dirname(path))
|
|
1143
|
+
pref.save()
|
|
1144
|
+
|
|
1145
|
+
self.loadFile(path)
|
|
1146
|
+
|
|
1147
|
+
def loadFile(self, path):
|
|
1148
|
+
pBar = QProgressDialog("Loading Shapes", "Cancel", 0, 100, self)
|
|
1149
|
+
pBar.show()
|
|
1150
|
+
QApplication.processEvents()
|
|
1151
|
+
|
|
1152
|
+
# TODO: Come up with a better list of possibilites for loading
|
|
1153
|
+
# simplex files, and make the appropriate methods on the Simplex
|
|
1154
|
+
if path.endswith(".smpx"):
|
|
1155
|
+
newSystem = Simplex.buildSystemFromSmpx(
|
|
1156
|
+
path, self._currentObject, sliderMul=self._sliderMul, pBar=pBar
|
|
1157
|
+
)
|
|
1158
|
+
if newSystem is None:
|
|
1159
|
+
QMessageBox.warning(
|
|
1160
|
+
self,
|
|
1161
|
+
"Point Count Mismatch",
|
|
1162
|
+
"The .smpx file point count does not match the current object",
|
|
1163
|
+
)
|
|
1164
|
+
pBar.close()
|
|
1165
|
+
return
|
|
1166
|
+
|
|
1167
|
+
elif path.endswith(".json"):
|
|
1168
|
+
newSystem = Simplex.buildSystemFromJson(
|
|
1169
|
+
path, self._currentObject, sliderMul=self._sliderMul, pBar=pBar
|
|
1170
|
+
)
|
|
1171
|
+
else:
|
|
1172
|
+
QMessageBox.warning(self, "Bad Filepath", "Path type not recognized")
|
|
1173
|
+
return
|
|
1174
|
+
|
|
1175
|
+
with signalsBlocked(self.uiCurrentSystemCBOX):
|
|
1176
|
+
self.loadObject(newSystem.DCC.mesh)
|
|
1177
|
+
idx = self.uiCurrentSystemCBOX.findText(self._currentObjectName)
|
|
1178
|
+
if idx >= 0:
|
|
1179
|
+
self.uiCurrentSystemCBOX.setCurrentIndex(idx)
|
|
1180
|
+
else:
|
|
1181
|
+
self.uiCurrentSystemCBOX.addItem(newSystem.name)
|
|
1182
|
+
self.uiCurrentSystemCBOX.setCurrentIndex(
|
|
1183
|
+
self.uiCurrentSystemCBOX.count() - 1
|
|
1184
|
+
)
|
|
1185
|
+
|
|
1186
|
+
self.setSystem(newSystem)
|
|
1187
|
+
pBar.close()
|
|
1188
|
+
self.simplex.DCC.checkForErrors(self)
|
|
1189
|
+
|
|
1190
|
+
def _fileDialog(self, title, initPath, filters, save=True):
|
|
1191
|
+
"""Convenience function for displaying File Dialogs"""
|
|
1192
|
+
filters = ["{0} (*.{0})".format(f) for f in filters]
|
|
1193
|
+
if not save:
|
|
1194
|
+
filters += ["All files (*.*)"]
|
|
1195
|
+
filters = ";;".join(filters)
|
|
1196
|
+
|
|
1197
|
+
if save:
|
|
1198
|
+
path, _ = QtCompat.QFileDialog.getSaveFileName(
|
|
1199
|
+
self, title, initPath, filters
|
|
1200
|
+
)
|
|
1201
|
+
else:
|
|
1202
|
+
path, _ = QtCompat.QFileDialog.getOpenFileName(
|
|
1203
|
+
self, title, initPath, filters
|
|
1204
|
+
)
|
|
1205
|
+
|
|
1206
|
+
if not path:
|
|
1207
|
+
return ""
|
|
1208
|
+
|
|
1209
|
+
if not save and not os.path.exists(path):
|
|
1210
|
+
return ""
|
|
1211
|
+
|
|
1212
|
+
return path
|
|
1213
|
+
|
|
1214
|
+
def exportSystemTemplate(self):
|
|
1215
|
+
"""Open a file dialog and export a system to the chosen path"""
|
|
1216
|
+
if self._currentObject is None:
|
|
1217
|
+
QMessageBox.warning(self, "Warning", "Must have a current object selection")
|
|
1218
|
+
return
|
|
1219
|
+
|
|
1220
|
+
pref = Prefs()
|
|
1221
|
+
defaultPath = str(
|
|
1222
|
+
pref.restoreProperty(
|
|
1223
|
+
"systemExport", os.path.join(os.path.expanduser("~"))
|
|
1224
|
+
)
|
|
1225
|
+
)
|
|
1226
|
+
path = self._fileDialog(
|
|
1227
|
+
"Export Template", defaultPath, ["smpx", "json"], save=True
|
|
1228
|
+
)
|
|
1229
|
+
if not path:
|
|
1230
|
+
return
|
|
1231
|
+
pref.recordProperty("systemExport", os.path.dirname(path))
|
|
1232
|
+
pref.save()
|
|
1233
|
+
|
|
1234
|
+
if self.simplex is None:
|
|
1235
|
+
QMessageBox.warning(self, "Warning", "No simplex loaded")
|
|
1236
|
+
return
|
|
1237
|
+
|
|
1238
|
+
if path.endswith(".smpx"):
|
|
1239
|
+
pBar = QProgressDialog("Exporting smpx File", "Cancel", 0, 100, self)
|
|
1240
|
+
pBar.show()
|
|
1241
|
+
self.simplex.exportAbc(path, pBar)
|
|
1242
|
+
pBar.close()
|
|
1243
|
+
elif path.endswith(".json"):
|
|
1244
|
+
dump = self.simplex.dump()
|
|
1245
|
+
with open(path, "w") as f:
|
|
1246
|
+
f.write(dump)
|
|
1247
|
+
|
|
1248
|
+
# Slider Settings
|
|
1249
|
+
def setSelectedSliderGroups(self, group):
|
|
1250
|
+
"""Set the group for the selected Sliders
|
|
1251
|
+
|
|
1252
|
+
Parameters
|
|
1253
|
+
----------
|
|
1254
|
+
group : Group
|
|
1255
|
+
The group that will take the selected Sliders
|
|
1256
|
+
"""
|
|
1257
|
+
if not group:
|
|
1258
|
+
return
|
|
1259
|
+
sliders = self.uiSliderTREE.getSelectedItems(Slider)
|
|
1260
|
+
group.take(sliders)
|
|
1261
|
+
self.uiSliderTREE.viewport().update()
|
|
1262
|
+
|
|
1263
|
+
def setSelectedSliderFalloff(self, falloff, state):
|
|
1264
|
+
"""Set the Falloffs for the selected Sliders
|
|
1265
|
+
|
|
1266
|
+
Parameters
|
|
1267
|
+
----------
|
|
1268
|
+
falloff : Falloff
|
|
1269
|
+
The falloff to set on the selected sliders
|
|
1270
|
+
state : bool
|
|
1271
|
+
Whether to add or remove this falloff from the selection
|
|
1272
|
+
"""
|
|
1273
|
+
if not falloff:
|
|
1274
|
+
return
|
|
1275
|
+
sliders = self.uiSliderTREE.getSelectedItems(Slider)
|
|
1276
|
+
for s in sliders:
|
|
1277
|
+
if state == Qt.Checked:
|
|
1278
|
+
s.prog.addFalloff(falloff)
|
|
1279
|
+
else:
|
|
1280
|
+
s.prog.removeFalloff(falloff)
|
|
1281
|
+
self.uiSliderTREE.viewport().update()
|
|
1282
|
+
|
|
1283
|
+
def setSelectedSliderInterp(self, interp):
|
|
1284
|
+
"""Set the interpolation for the selected sliders
|
|
1285
|
+
|
|
1286
|
+
Parameters
|
|
1287
|
+
----------
|
|
1288
|
+
interp : str
|
|
1289
|
+
The interpolation to set on the selection.
|
|
1290
|
+
Could be 'linear', 'spline', or 'splitSpline'
|
|
1291
|
+
"""
|
|
1292
|
+
sliders = self.uiSliderTREE.getSelectedItems(Slider)
|
|
1293
|
+
for s in sliders:
|
|
1294
|
+
s.prog.interp = interp
|
|
1295
|
+
|
|
1296
|
+
# Combo Settings
|
|
1297
|
+
def setSelectedComboGroups(self, group):
|
|
1298
|
+
"""Set the group for the selected Combos
|
|
1299
|
+
|
|
1300
|
+
Parameters
|
|
1301
|
+
----------
|
|
1302
|
+
group : Group
|
|
1303
|
+
The group that will take the selected Combos
|
|
1304
|
+
"""
|
|
1305
|
+
if not group:
|
|
1306
|
+
return
|
|
1307
|
+
combos = self.uiComboTREE.getSelectedItems(Combo)
|
|
1308
|
+
group.take(combos)
|
|
1309
|
+
self.uiComboTREE.viewport().update()
|
|
1310
|
+
|
|
1311
|
+
def setSelectedComboSolveType(self, stVal):
|
|
1312
|
+
"""Set the solve type for the selected combos
|
|
1313
|
+
|
|
1314
|
+
Parameters
|
|
1315
|
+
----------
|
|
1316
|
+
stVal : str
|
|
1317
|
+
The solve type to set for the combos.
|
|
1318
|
+
See Combo.solveTypes for a list
|
|
1319
|
+
"""
|
|
1320
|
+
combos = self.uiComboTREE.getSelectedItems(Combo)
|
|
1321
|
+
for c in combos:
|
|
1322
|
+
c.solveType = stVal
|
|
1323
|
+
|
|
1324
|
+
# Edit Menu
|
|
1325
|
+
def hideRedundant(self):
|
|
1326
|
+
"""Hide redundant items from the Slider and Combo trees based on a user preference"""
|
|
1327
|
+
check = self.uiHideRedundantACT.isChecked()
|
|
1328
|
+
comboModel = self.uiComboTREE.model()
|
|
1329
|
+
comboModel.filterShapes = check
|
|
1330
|
+
comboModel.invalidateFilter()
|
|
1331
|
+
sliderModel = self.uiSliderTREE.model()
|
|
1332
|
+
sliderModel.doFilter = check
|
|
1333
|
+
sliderModel.invalidateFilter()
|
|
1334
|
+
|
|
1335
|
+
def setSliderRange(self):
|
|
1336
|
+
"""Double the range for the sliders *IN THE DCC ONLY* based on a user preference"""
|
|
1337
|
+
self._sliderMul = 2.0 if self.uiDoubleSliderRangeACT.isChecked() else 1.0
|
|
1338
|
+
if self.simplex is None:
|
|
1339
|
+
return
|
|
1340
|
+
self.simplex.DCC.sliderMul = self._sliderMul
|
|
1341
|
+
self.simplex.DCC.setSlidersRange(self.simplex.sliders)
|
|
1342
|
+
|
|
1343
|
+
# Isolation
|
|
1344
|
+
def isSliderIsolate(self):
|
|
1345
|
+
"""Check if the slider tree is currently isolated"""
|
|
1346
|
+
model = self.uiSliderTREE.model()
|
|
1347
|
+
if model:
|
|
1348
|
+
return bool(model.isolateList)
|
|
1349
|
+
return False
|
|
1350
|
+
|
|
1351
|
+
def sliderIsolateSelected(self):
|
|
1352
|
+
"""Isolate the selected Sliders in the Slider Tree"""
|
|
1353
|
+
self.uiSliderTREE.isolateSelected()
|
|
1354
|
+
self.uiSliderExitIsolateBTN.show()
|
|
1355
|
+
|
|
1356
|
+
def sliderTreeExitIsolate(self):
|
|
1357
|
+
"""Disable isolation mode in the Slider Tree"""
|
|
1358
|
+
self.uiSliderTREE.exitIsolate()
|
|
1359
|
+
self.uiSliderExitIsolateBTN.hide()
|
|
1360
|
+
|
|
1361
|
+
def isComboIsolate(self):
|
|
1362
|
+
"""Check if the combo tree is currently isolated"""
|
|
1363
|
+
model = self.uiComboTREE.model()
|
|
1364
|
+
if model:
|
|
1365
|
+
return bool(model.isolateList)
|
|
1366
|
+
return False
|
|
1367
|
+
|
|
1368
|
+
def comboIsolateSelected(self):
|
|
1369
|
+
"""Isolate the selected Combos in the Combo Tree"""
|
|
1370
|
+
self.uiComboTREE.isolateSelected()
|
|
1371
|
+
self.uiComboExitIsolateBTN.show()
|
|
1372
|
+
|
|
1373
|
+
def comboTreeExitIsolate(self):
|
|
1374
|
+
"""Disable isolation mode in the Combo Tree"""
|
|
1375
|
+
self.uiComboTREE.exitIsolate()
|
|
1376
|
+
self.uiComboExitIsolateBTN.hide()
|
|
1377
|
+
|
|
1378
|
+
|
|
1379
|
+
def _test():
|
|
1380
|
+
app = QApplication(sys.argv)
|
|
1381
|
+
path = r"C:\Users\tfox\Documents\GitHub\Simplex\scripts\SimplexUI\build\HeadMaleStandard_High_Unsplit.smpx"
|
|
1382
|
+
d = SimplexDialog()
|
|
1383
|
+
newSystem = Simplex.buildSystemFromSmpx(path, d.getCurrentObject(), sliderMul=1.0)
|
|
1384
|
+
d.setSystem(newSystem)
|
|
1385
|
+
|
|
1386
|
+
d.show()
|
|
1387
|
+
sys.exit(app.exec_())
|
|
1388
|
+
|
|
1389
|
+
|
|
1390
|
+
if __name__ == "__main__":
|
|
1391
|
+
_test()
|