Skip to content

Commit 894fb48

Browse files
committed
Shifter: EPIC_control_01: add backwards_ref_jnt setting Closes #523
1 parent 6312551 commit 894fb48

3 files changed

Lines changed: 121 additions & 6 deletions

File tree

release/scripts/mgear/shifter_epic_components/EPIC_control_01/guide.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def addParameters(self):
6767
self.pIcon = self.addParam("icon", "string", "cube")
6868

6969
self.pIkRefArray = self.addParam("ikrefarray", "string", "")
70+
self.pBackwardsRefJnt = self.addParam("backwards_ref_jnt", "string", "")
7071

7172
self.pJoint = self.addParam("joint", "bool", False)
7273
self.pUniScale = self.addParam("uniScale", "bool", False)
@@ -209,6 +210,9 @@ def populate_componentControls(self):
209210
comboIndex = self.connector_items.index(currentConnector)
210211
self.mainSettingsTab.connector_comboBox.setCurrentIndex(comboIndex)
211212

213+
self.settingsTab.backwards_ref_jnt_lineEdit.setText(
214+
self.root.attr("backwards_ref_jnt").get())
215+
212216
def create_componentLayout(self):
213217

214218
self.settings_layout = QtWidgets.QVBoxLayout()
@@ -293,6 +297,43 @@ def create_componentConnections(self):
293297
)
294298
)
295299

300+
self.settingsTab.backwards_ref_jnt_pushButton.clicked.connect(
301+
partial(self.updateFallbackJoint,
302+
self.settingsTab.backwards_ref_jnt_lineEdit,
303+
"backwards_ref_jnt"))
304+
305+
def updateFallbackJoint(self, lEdit, targetAttr):
306+
"""Update line edit with selected joint name if valid.
307+
308+
This method checks if the selected object is a joint and sets the
309+
line edit text and corresponding attribute on the root.
310+
311+
Args:
312+
lEdit (QLineEdit): Line edit widget to populate.
313+
targetAttr (str): Attribute name on root to update.
314+
315+
Returns:
316+
None
317+
"""
318+
oSel = pm.selected()
319+
if oSel:
320+
node = oSel[0]
321+
if node == self.root:
322+
pm.displayWarning("Root joint cannot be used as fallback.")
323+
return
324+
325+
if pm.nodeType(node) == "joint":
326+
lEdit.setText(node.name())
327+
self.root.attr(targetAttr).set(lEdit.text())
328+
else:
329+
pm.displayWarning("Selected element is not a joint.")
330+
else:
331+
pm.displayWarning("Nothing selected.")
332+
if lEdit.text():
333+
lEdit.clear()
334+
self.root.attr(targetAttr).set("")
335+
pm.displayWarning("Fallback joint reference has been cleared.")
336+
296337
def eventFilter(self, sender, event):
297338
if event.type() == QtCore.QEvent.ChildRemoved:
298339
if sender == self.settingsTab.ikRefArray_listWidget:

release/scripts/mgear/shifter_epic_components/EPIC_control_01/settingsUI.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
class Ui_Form(object):
55
def setupUi(self, Form):
66
Form.setObjectName("Form")
7-
Form.resize(591, 713)
7+
Form.resize(591, 805)
88
self.gridLayout = QtWidgets.QGridLayout(Form)
99
self.gridLayout.setObjectName("gridLayout")
1010
self.groupBox = QtWidgets.QGroupBox(Form)
@@ -154,7 +154,7 @@ def setupUi(self, Form):
154154
self.verticalLayout_3.addItem(spacerItem2)
155155
self.horizontalLayout.addLayout(self.verticalLayout_3)
156156
self.gridLayout_4.addLayout(self.horizontalLayout, 0, 0, 1, 1)
157-
self.gridLayout.addWidget(self.keyable_groupBox, 1, 0, 1, 1)
157+
self.gridLayout.addWidget(self.keyable_groupBox, 2, 0, 1, 1)
158158
self.ikRefArray_groupBox = QtWidgets.QGroupBox(Form)
159159
self.ikRefArray_groupBox.setObjectName("ikRefArray_groupBox")
160160
self.gridLayout_3 = QtWidgets.QGridLayout(self.ikRefArray_groupBox)
@@ -185,7 +185,29 @@ def setupUi(self, Form):
185185
self.ikRefArray_verticalLayout_2.addItem(spacerItem3)
186186
self.ikRefArray_horizontalLayout.addLayout(self.ikRefArray_verticalLayout_2)
187187
self.gridLayout_3.addLayout(self.ikRefArray_horizontalLayout, 0, 0, 1, 1)
188-
self.gridLayout.addWidget(self.ikRefArray_groupBox, 2, 0, 1, 1)
188+
self.gridLayout.addWidget(self.ikRefArray_groupBox, 3, 0, 1, 1)
189+
self.groupBox_4 = QtWidgets.QGroupBox(Form)
190+
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
191+
sizePolicy.setHorizontalStretch(0)
192+
sizePolicy.setVerticalStretch(0)
193+
sizePolicy.setHeightForWidth(self.groupBox_4.sizePolicy().hasHeightForWidth())
194+
self.groupBox_4.setSizePolicy(sizePolicy)
195+
self.groupBox_4.setObjectName("groupBox_4")
196+
self.gridLayout_5 = QtWidgets.QGridLayout(self.groupBox_4)
197+
self.gridLayout_5.setObjectName("gridLayout_5")
198+
self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
199+
self.horizontalLayout_4.setObjectName("horizontalLayout_4")
200+
self.label_2 = QtWidgets.QLabel(self.groupBox_4)
201+
self.label_2.setObjectName("label_2")
202+
self.horizontalLayout_4.addWidget(self.label_2)
203+
self.backwards_ref_jnt_lineEdit = QtWidgets.QLineEdit(self.groupBox_4)
204+
self.backwards_ref_jnt_lineEdit.setObjectName("backwards_ref_jnt_lineEdit")
205+
self.horizontalLayout_4.addWidget(self.backwards_ref_jnt_lineEdit)
206+
self.backwards_ref_jnt_pushButton = QtWidgets.QPushButton(self.groupBox_4)
207+
self.backwards_ref_jnt_pushButton.setObjectName("backwards_ref_jnt_pushButton")
208+
self.horizontalLayout_4.addWidget(self.backwards_ref_jnt_pushButton)
209+
self.gridLayout_5.addLayout(self.horizontalLayout_4, 0, 0, 1, 1)
210+
self.gridLayout.addWidget(self.groupBox_4, 1, 0, 1, 1)
189211

190212
self.retranslateUi(Form)
191213
QtCore.QObject.connect(self.translate_pushButton, QtCore.SIGNAL("clicked()"), self.tx_checkBox.toggle)
@@ -247,4 +269,10 @@ def retranslateUi(self, Form):
247269
self.ikRefArray_groupBox.setTitle(gqt.fakeTranslate("Form", "IK Reference Array", None, -1))
248270
self.ikRefArrayAdd_pushButton.setText(gqt.fakeTranslate("Form", "<<", None, -1))
249271
self.ikRefArrayRemove_pushButton.setText(gqt.fakeTranslate("Form", ">>", None, -1))
272+
self.groupBox_4.setTitle(gqt.fakeTranslate("Form", "UE Control Rig Settings", None, -1))
273+
self.label_2.setToolTip(gqt.fakeTranslate("Form", "<html><head/><body><p>Specifies the fallback reference joint to use for Unreal Control Rig backward solve when the control has no associated joint.</p></body></html>", None, -1))
274+
self.label_2.setText(gqt.fakeTranslate("Form", "Backward Solve Reference Joint", None, -1))
275+
self.backwards_ref_jnt_lineEdit.setToolTip(gqt.fakeTranslate("Form", "<html><head/><body><p>Specifies the fallback reference joint to use for Unreal Control Rig backward solve when the control has no associated joint.</p></body></html>", None, -1))
276+
self.backwards_ref_jnt_pushButton.setToolTip(gqt.fakeTranslate("Form", "<html><head/><body><p>Specifies the fallback reference joint to use for Unreal Control Rig backward solve when the control has no associated joint.</p></body></html>", None, -1))
277+
self.backwards_ref_jnt_pushButton.setText(gqt.fakeTranslate("Form", "<<", None, -1))
250278

release/scripts/mgear/shifter_epic_components/EPIC_control_01/settingsUI.ui

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>591</width>
10-
<height>713</height>
10+
<height>805</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -217,7 +217,7 @@
217217
</layout>
218218
</widget>
219219
</item>
220-
<item row="1" column="0">
220+
<item row="2" column="0">
221221
<widget class="QGroupBox" name="keyable_groupBox">
222222
<property name="title">
223223
<string>Keyable</string>
@@ -405,7 +405,7 @@
405405
</layout>
406406
</widget>
407407
</item>
408-
<item row="2" column="0">
408+
<item row="3" column="0">
409409
<widget class="QGroupBox" name="ikRefArray_groupBox">
410410
<property name="title">
411411
<string>IK Reference Array</string>
@@ -475,6 +475,52 @@
475475
</layout>
476476
</widget>
477477
</item>
478+
<item row="1" column="0">
479+
<widget class="QGroupBox" name="groupBox_4">
480+
<property name="sizePolicy">
481+
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
482+
<horstretch>0</horstretch>
483+
<verstretch>0</verstretch>
484+
</sizepolicy>
485+
</property>
486+
<property name="title">
487+
<string>UE Control Rig Settings</string>
488+
</property>
489+
<layout class="QGridLayout" name="gridLayout_5">
490+
<item row="0" column="0">
491+
<layout class="QHBoxLayout" name="horizontalLayout_4">
492+
<item>
493+
<widget class="QLabel" name="label_2">
494+
<property name="toolTip">
495+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Specifies the fallback reference joint to use for Unreal Control Rig backward solve when the control has no associated joint.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
496+
</property>
497+
<property name="text">
498+
<string>Backward Solve Reference Joint</string>
499+
</property>
500+
</widget>
501+
</item>
502+
<item>
503+
<widget class="QLineEdit" name="backwards_ref_jnt_lineEdit">
504+
<property name="toolTip">
505+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Specifies the fallback reference joint to use for Unreal Control Rig backward solve when the control has no associated joint.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
506+
</property>
507+
</widget>
508+
</item>
509+
<item>
510+
<widget class="QPushButton" name="backwards_ref_jnt_pushButton">
511+
<property name="toolTip">
512+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Specifies the fallback reference joint to use for Unreal Control Rig backward solve when the control has no associated joint.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
513+
</property>
514+
<property name="text">
515+
<string>&lt;&lt;</string>
516+
</property>
517+
</widget>
518+
</item>
519+
</layout>
520+
</item>
521+
</layout>
522+
</widget>
523+
</item>
478524
</layout>
479525
</widget>
480526
<resources/>

0 commit comments

Comments
 (0)