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
|
# -*- coding: utf-8 -*-
"""
:author:
Jeremy Ernst
:description:
This module contains the class for creating and displaying the load template interface.
"""
import artv2.utilities.interface_utilities as interface_utils
from artv2.third_party.Qt import QtWidgets
import artv2.tools.system.logger.output_logger as logger
import artv2.utilities.general_utilities as utils
import artv2.components.base_components.template as template
import pymel.core as pm
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
class LoadTemplateUI(interface_utils.ARTv2Window):
"""
This class creates the Load Template interface for loading a template from disk. The interface allows the user to
select components to load, as well as what information to load (positions, settings, overrides) and that information
is then passed onto the template class for processing. This is invoked from the RigBuilderUI toolbar.
:param path: the path on disk of a template file.
:param parent: the instance of the RigBuilderUI this widget will be parented to
.. figure:: /images/loadTemplateUI.png
:width: 382px
:align: center
:height: 304px
:figclass: align-center
"""
SETTINGS_NAME = "LoadTemplateWIN"
WINDOW_NAME = "artv2_load_template_window"
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def __init__(self, path, parent=None):
super(LoadTemplateUI, self).__init__(380, 270, "Load Template", parent)
self.path = path
self.parent_inst = parent
self.logger = logger.OutputLogger(self.__class__.__name__)
self._build_interface()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def _build_interface(self):
main_widget = QtWidgets.QWidget()
main_layout = QtWidgets.QHBoxLayout(main_widget)
self.setCentralWidget(main_widget)
self.component_list = QtWidgets.QListWidget()
self.component_list.setSortingEnabled(True)
self.component_list.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
self.component_list.setMinimumWidth(interface_utils.scale_by_dpi(170))
self.component_list.setMaximumWidth(interface_utils.scale_by_dpi(170))
main_layout.addWidget(self.component_list)
right_layout = QtWidgets.QVBoxLayout()
main_layout.addLayout(right_layout)
self.settings_checkbox = QtWidgets.QCheckBox("Load Settings")
self.settings_checkbox.setToolTip("Load settings for the selected components.")
self.settings_checkbox.setChecked(True)
self.positions_checkbox = QtWidgets.QCheckBox("Load Positions")
self.positions_checkbox.setToolTip("Load positions for the selected components.")
self.positions_checkbox.setChecked(True)
self.overrides_checkbox = QtWidgets.QCheckBox("Load Joint Name Overrides")
self.overrides_checkbox.setToolTip("Load joint name overrides for the selected components.")
self.overrides_checkbox.setChecked(True)
self.aim_checkbox = QtWidgets.QCheckBox("Turn on Aim Mode")
self.aim_checkbox.setChecked(False)
self.aim_checkbox.setToolTip("When a component is loaded, should aim mode automatically be turned on?")
right_layout.addWidget(self.settings_checkbox)
right_layout.addWidget(self.positions_checkbox)
right_layout.addWidget(self.overrides_checkbox)
right_layout.addWidget(self.aim_checkbox)
spacer = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding)
right_layout.addSpacerItem(spacer)
button = QtWidgets.QPushButton("Load Selected")
button.clicked.connect(self._load)
right_layout.addWidget(button)
self._populate_list()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def _populate_list(self):
data = utils.load_from_file(self.path)
for key in data.keys():
self.component_list.addItem(key)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def _load(self):
self.logger.interface("{0}._load: Loading template.".format(self.__class__.__name__))
components = []
selected_items = self.component_list.selectedItems()
for each in selected_items:
components.append(each.text())
template_instance = template.Template(self.path)
template_instance.load_settings = self.settings_checkbox.isChecked()
template_instance.load_positions = self.positions_checkbox.isChecked()
template_instance.load_overrides = self.overrides_checkbox.isChecked()
aim = self.aim_checkbox.isChecked()
template_instance.load_template(components, aim=aim)
self.close()
self.parent_inst.update_list()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def show_window(parent, path):
"""
Shows the LoadTemplateUI instance
"""
if pm.window("artv2_load_template_window", exists=True):
pm.deleteUI("artv2_load_template_window")
gui = LoadTemplateUI(path, parent)
gui.show()
|