-
Notifications
You must be signed in to change notification settings - Fork 1
/
gui_blendshape_tools.py
236 lines (185 loc) · 8.13 KB
/
gui_blendshape_tools.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# rigmarole-tools/gui_blendshape_tools.py
""" WIP development of PySide GUI for blendshape_tools """
try:
import PySide2.QtCore as QtCore
import PySide2.QtGui as QtGui
import PySide2.QtWidgets as QtWidgets
except ImportError:
print("failed to import PySide2, {}".format(__file__))
import PySide.QtCore as QtCore
import PySide.QtGui as QtGui
import PySide.QtWidgets as QtWidgets
try:
# future proofing for Maya 2017.
from shiboken2 import wrapInstance
except ImportError:
from shiboken import wrapInstance
class BlendshapeToolsWindow(QtWidgets.QMainWindow):
volumeSliderChanged = QtCore.Signal(str)
softnessSliderChanged = QtCore.Signal(str)
chooseNeutralClicked = QtCore.Signal(str)
chooseGeoToSplitClicked = QtCore.Signal(str)
smashGeoButtonClicked = QtCore.Signal(str)
splitBlendshapesClicked = QtCore.Signal(str)
splitBlendshapesSoftClicked = QtCore.Signal(str)
chooseSmashGeoClicked = QtCore.Signal(str)
def create_window():
window = BlendshapeToolsWindow()
window.setWindowTitle('Rigmarole Blendshape Tools')
#############################
###### CREATE ELEMENTS ######
#############################
container = QtWidgets.QWidget(window)
horizontal = QtCore.Qt.Horizontal
groupFont = QtGui.QFont('Helvetica Neue', 10, QtGui.QFont.Bold)
volumeLabel = QtWidgets.QLabel('Intensity')
volumeSlider = QtWidgets.QSlider(orientation=horizontal, minimum=0, maximum=100)
volumeSlider.setSliderPosition(100)
volumeIndicator = QtWidgets.QLineEdit(maximumWidth=80)
volumeResult = round(volumeSlider.value() * 0.01, 3)
#TODO: Change this string indicator to an integer instead
volumeIndicator.setText(str(volumeResult))
softnessLabel = QtWidgets.QLabel('Softness')
softnessSlider = QtWidgets.QSlider(orientation=horizontal, minimum=0, maximum=100)
softnessSlider.setSliderPosition(0)
softnessIndicator = QtWidgets.QLineEdit(maximumWidth=80)
softnessResult = round(softnessSlider.value() * 0.01, 3)
#TODO: Change this string indicator to an integer instead
softnessIndicator.setText(str(softnessResult))
falloffLabel = QtWidgets.QLabel('Falloff Easing')
falloffDropdown = QtWidgets.QComboBox()
falloffDropdown.addItem('Linear 1')
falloffDropdown.addItem('Cubic 3')
falloffDropdown.addItem('Quadratic 4')
falloffDropdown.setCurrentIndex(2)
button = QtWidgets.QPushButton('Choose Neutral Geo:', container)
splitGeoButton = QtWidgets.QPushButton('Choose Geo to Split:', container)
textbox = QtWidgets.QLineEdit(container)
splitGeoField = QtWidgets.QLineEdit(container)
chooseSmashGeoButton = QtWidgets.QPushButton('Choose Geo to Change:', container)
smashGeoField = QtWidgets.QLineEdit()
smashGeoButton = QtWidgets.QPushButton('Vertex Smash', container)
splitBlendshapesButton = QtWidgets.QPushButton('Split Blendshapes using Helpers', container)
splitBlendshapesSoftButton = QtWidgets.QPushButton('Split Blendshapes by Soft Selection', container)
##########################
###### SIGNAL EMITS ######
##########################
def onchange():
volumeResult = round(volumeSlider.value() * 0.01, 3)
volumeIndicator.setText(str(volumeResult))
window.volumeSliderChanged.emit(volumeSlider.value())
volumeSlider.valueChanged.connect(onchange)
def onchange():
softnessResult = round(softnessSlider.value() * 0.01, 3)
softnessIndicator.setText(str(softnessResult))
window.softnessSliderChanged.emit(softnessSlider.value())
softnessSlider.valueChanged.connect(onchange)
def onclick():
window.chooseNeutralClicked.emit(textbox.text())
button.clicked.connect(onclick)
def onclick():
window.chooseGeoToSplitClicked.emit(splitGeoField.text())
splitGeoButton.clicked.connect(onclick)
def onclick():
window.smashGeoButtonClicked.emit(smashGeoField.text())
smashGeoButton.clicked.connect(onclick)
def onclick():
window.chooseSmashGeoClicked.emit(smashGeoField.text())
chooseSmashGeoButton.clicked.connect(onclick)
def onclick():
window.splitBlendshapesClicked.emit(splitGeoField.text())
splitBlendshapesButton.clicked.connect(onclick)
def onclick():
window.splitBlendshapesSoftClicked.emit(splitGeoField.text())
splitBlendshapesSoftButton.clicked.connect(onclick)
##########################
###### SIGNAL SLOTS ######
##########################
def onVolumeSliderChanged(message):
pass
window.volumeSliderChanged.connect(onVolumeSliderChanged)
def onSoftnessSliderChanged(message):
pass
window.softnessSliderChanged.connect(onSoftnessSliderChanged)
def onChooseNeutralClicked(message):
print('Choose neutral geo clicked. Message:', message)
window.chooseNeutralClicked.connect(onChooseNeutralClicked)
def onChooseSplitClicked(message):
print('Choose split geo clicked. Message:', message)
window.chooseGeoToSplitClicked.connect(onChooseSplitClicked)
def onSmashVertexClicked(message):
print('Smash Vertex clicked. Message:', message)
window.smashGeoButtonClicked.connect(onSmashVertexClicked)
def onSplitBlendshapesClicked(message):
print('Split Blendshapes by Helper clicked. Message:', message)
window.splitBlendshapesClicked.connect(onSplitBlendshapesClicked)
def onSplitBlendshapesSoftClicked(message):
print('Split Blendshapes by Soft Selection clicked. Message:', message)
window.splitBlendshapesSoftClicked.connect(onSplitBlendshapesSoftClicked)
def onChooseSmashGeoClicked(message):
print('Choose Smash Geo clicked. Message:', message)
window.chooseSmashGeoClicked.connect(onChooseSmashGeoClicked)
#########################
###### MAIN LAYOUT ######
#########################
mainLayout = QtWidgets.QVBoxLayout(container)
# LAYOUT: volume intensity slider
layout0 = QtWidgets.QHBoxLayout()
layout0.addWidget(volumeLabel)
layout0.addWidget(volumeSlider)
layout0.addWidget(volumeIndicator)
# LAYOUT: softness intensity slider
layout6 = QtWidgets.QHBoxLayout()
layout6.addWidget(softnessLabel)
layout6.addWidget(softnessSlider)
layout6.addWidget(softnessIndicator)
# LAYOUT: Falloff Easing dropdown box
layout1 = QtWidgets.QHBoxLayout()
layout1.addWidget(falloffLabel)
layout1.addWidget(falloffDropdown)
# LAYOUT: Random buttons for testing
layout2 = QtWidgets.QHBoxLayout()
layout2.addWidget(button)
layout2.addWidget(textbox)
# LAYOUT: Split geometry chooser
layout3 = QtWidgets.QHBoxLayout()
layout3.addWidget(splitGeoButton)
layout3.addWidget(splitGeoField)
# LAYOUT: Split blendshapes operation buttons
layout5 = QtWidgets.QVBoxLayout()
layout5.addWidget(splitBlendshapesButton)
layout5.addWidget(splitBlendshapesSoftButton)
# LAYOUT: Choose smash geo and smash button
layout4 = QtWidgets.QHBoxLayout()
layout4.addWidget(chooseSmashGeoButton)
layout4.addWidget(smashGeoField)
layout4.addWidget(smashGeoButton)
group0 = QtWidgets.QGroupBox('Options')
group0.setFont(groupFont)
optionsLayout = QtWidgets.QVBoxLayout()
optionsLayout.addLayout(layout0)
optionsLayout.addLayout(layout6)
group0.setLayout(optionsLayout)
group1 = QtWidgets.QGroupBox('Split Blendshapes')
group1.setFont(groupFont)
splitBlendshapeLayout = QtWidgets.QVBoxLayout()
splitBlendshapeLayout.addLayout(layout1)
splitBlendshapeLayout.addLayout(layout2)
splitBlendshapeLayout.addLayout(layout3)
splitBlendshapeLayout.addLayout(layout5)
group1.setLayout(splitBlendshapeLayout)
group2 = QtWidgets.QGroupBox('Vertex Smash')
group2.setFont(groupFont)
vertexSmashLayout = QtWidgets.QVBoxLayout()
vertexSmashLayout.addLayout(layout4)
group2.setLayout(vertexSmashLayout)
mainLayout.addWidget(group0)
mainLayout.addWidget(group1)
mainLayout.addWidget(group2)
window.setCentralWidget(container)
return window
if __name__ == '__main__':
app = QtWidgets.QApplication([])
win = create_window()
win.show()
app.exec_()