blob: 65eb66f6924c015bdec167eb6f6c13e9dc02427f (
plain) (
blame)
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
|
# -*- coding: utf-8 -*-
"""
:author:
Jeremy Ernst
:description:
This module contains a class that presents a widget for setting the parent joint of a component.
"""
import os
from artv2.third_party.Qt import QtWidgets, QtCore, QtGui
import artv2.utilities.interface_utilities as interface_utils
import artv2.utilities.component_utilities as component_utils
import artv2.tools.rigging.rig_builder.parent_list_widget as parent_list
import pymel.core as pm
class SetParentWidget(interface_utils.ARTv2Window):
"""
This class presents a widget for setting the parent joint of a component. It is invoked from the
ComponentContextMenu.
:param metanode: string name of the component’s network node that the parent will be set on.
:param parent: the instance of the RigBuilderUI which will be this widget’s parent.
.. figure:: /images/set_parent_widget.png
:width: 220px
:align: center
:height: 108px
:figclass: align-center
"""
SETTINGS_NAME = "SetComponentParentWIN"
WINDOW_NAME = "artv2_set_component_parent_window"
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def __init__(self, metanode, parent=None):
super(SetParentWidget, self).__init__(220, 50, "Set Parent", parent)
self.metanode = pm.PyNode(metanode)
self._build_interface()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def _build_interface(self):
main_widget = QtWidgets.QWidget()
self.setCentralWidget(main_widget)
main_layout = QtWidgets.QVBoxLayout(main_widget)
parent_layout = QtWidgets.QHBoxLayout()
main_layout.addLayout(parent_layout)
parent_label = QtWidgets.QLabel("Parent:")
parent_label.setMinimumWidth(interface_utils.scale_by_dpi(40))
parent_label.setMaximumWidth(interface_utils.scale_by_dpi(40))
parent_layout.addWidget(parent_label)
self.parent_field = QtWidgets.QLineEdit()
parent_button = QtWidgets.QPushButton()
parent_button.setMinimumWidth(interface_utils.scale_by_dpi(25))
parent_button.setMaximumWidth(interface_utils.scale_by_dpi(25))
parent_button.setMinimumHeight(interface_utils.scale_by_dpi(25))
parent_button.setMaximumHeight(interface_utils.scale_by_dpi(25))
icon = QtGui.QIcon(os.path.join(self.icon_path, "general/search.png"))
parent_button.setIconSize(QtCore.QSize(21, 21))
parent_button.setIcon(icon)
parent_layout.addWidget(self.parent_field)
parent_layout.addWidget(parent_button)
self._populate_field()
completer = QtWidgets.QCompleter(component_utils.get_all_created_joints())
completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
self.parent_field.setCompleter(completer)
parent_button.clicked.connect(self._launch_parent_list)
button_layout = QtWidgets.QHBoxLayout()
main_layout.addLayout(button_layout)
cancel_button = QtWidgets.QPushButton("Cancel")
cancel_button.clicked.connect(self.close)
confirm_button = QtWidgets.QPushButton("Set Parent")
confirm_button.clicked.connect(self._set_parent)
button_layout.addWidget(cancel_button)
button_layout.addWidget(confirm_button)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def _populate_field(self):
inst = component_utils.get_component_instance(self.metanode)
self.parent_field.setText(inst.parent)
del inst
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def _launch_parent_list(self):
widget = parent_list.ChooseParentList(self)
pos = QtGui.QCursor.pos()
widget.move(pos.x() + 10, pos.y() + 10)
widget.exec_()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def _set_parent(self):
inst = component_utils.get_component_instance(self.metanode)
inst.parent = self.parent_field.text()
del inst
self.close()
|