This commit is contained in:
2025-05-07 01:31:21 +08:00
parent d27ef50341
commit 27240530b6
18 changed files with 2033 additions and 1160 deletions

View File

@@ -50,6 +50,8 @@ ASSETS_PATH = config.ASSETS_PATH
DNA_FILE_PATH = config.DNA_FILE_PATH
DNA_IMG_PATH = config.DNA_IMG_PATH
TOOL_COMMAND_ICON = config.TOOL_COMMAND_ICON
TOOL_WIDTH = config.TOOL_WIDTH
TOOL_HEIGHT = config.TOOL_HEIGHT
#========================================= LOCATION =======================================
from scripts.ui import localization
LANG = localization.LANG
@@ -643,12 +645,12 @@ class RiggingUI(ui_utils.BaseUI):
#======================================= FUNCTIONS ======================================
def create_connections(self):
"""
连接UI信号和槽
设置UI控件的事件处理函数
创建信号连接
"""
# 创建信号映射字典
signal_mapping = {
'buttons': {
# 绑定所有功能按钮
'add_joint_btn': {'signal': 'clicked', 'handler': utils_rigging.add_joint},
'remove_joint_btn': {'signal': 'clicked', 'handler': utils_rigging.remove_joint},
'duplicate_joint_btn': {'signal': 'clicked', 'handler': utils_rigging.duplicate_joint},
@@ -658,6 +660,12 @@ class RiggingUI(ui_utils.BaseUI):
'import_dna_btn': {'signal': 'clicked', 'handler': utils_rigging.import_dna},
'export_dna_btn': {'signal': 'clicked', 'handler': utils_rigging.export_dna},
'calibrate_dna_btn': {'signal': 'clicked', 'handler': utils_rigging.calibrate_dna},
# 已创建的按钮
'browse_path': {'signal': 'clicked', 'handler': lambda: utils_rigging.browse_file(self, "项目路径", self.controls["project_path_input"])},
'browse_dna': {'signal': 'clicked', 'handler': lambda: utils_rigging.browse_file(self, "DNA文件", self.controls["presets_dna_input"], "dna")},
'export_presets': {'signal': 'clicked', 'handler': utils_rigging.export_presets},
'import_presets': {'signal': 'clicked', 'handler': utils_rigging.import_presets},
},
'splitters': {
'main_splitter': {'signal': 'splitterMoved', 'handler': lambda pos, index: ui_utils.on_splitter_moved(self, pos, index)},
@@ -667,46 +675,5 @@ class RiggingUI(ui_utils.BaseUI):
# 使用ui_utils中的通用函数连接信号
ui_utils.connect_ui_signals(self, signal_mapping)
# 连接关节属性编辑控
if hasattr(self, 'joint_name_edit'):
self.joint_name_edit.editingFinished.connect(lambda: utils_rigging.handle_joint_name_changed(self.joint_name_edit))
# 关节位置编辑
if hasattr(self, 'joint_pos_x_spin'):
self.joint_pos_x_spin.valueChanged.connect(lambda val: utils_rigging.handle_joint_position_changed(0, [self.joint_pos_x_spin, self.joint_pos_y_spin, self.joint_pos_z_spin]))
if hasattr(self, 'joint_pos_y_spin'):
self.joint_pos_y_spin.valueChanged.connect(lambda val: utils_rigging.handle_joint_position_changed(1, [self.joint_pos_x_spin, self.joint_pos_y_spin, self.joint_pos_z_spin]))
if hasattr(self, 'joint_pos_z_spin'):
self.joint_pos_z_spin.valueChanged.connect(lambda val: utils_rigging.handle_joint_position_changed(2, [self.joint_pos_x_spin, self.joint_pos_y_spin, self.joint_pos_z_spin]))
# 关节旋转编辑
if hasattr(self, 'joint_rot_x_spin'):
self.joint_rot_x_spin.valueChanged.connect(lambda val: utils_rigging.handle_joint_rotation_changed(0, [self.joint_rot_x_spin, self.joint_rot_y_spin, self.joint_rot_z_spin]))
if hasattr(self, 'joint_rot_y_spin'):
self.joint_rot_y_spin.valueChanged.connect(lambda val: utils_rigging.handle_joint_rotation_changed(1, [self.joint_rot_x_spin, self.joint_rot_y_spin, self.joint_rot_z_spin]))
if hasattr(self, 'joint_rot_z_spin'):
self.joint_rot_z_spin.valueChanged.connect(lambda val: utils_rigging.handle_joint_rotation_changed(2, [self.joint_rot_x_spin, self.joint_rot_y_spin, self.joint_rot_z_spin]))
# 关节缩放编辑
if hasattr(self, 'joint_scale_x_spin'):
self.joint_scale_x_spin.valueChanged.connect(lambda val: utils_rigging.handle_joint_scale_changed(0, [self.joint_scale_x_spin, self.joint_scale_y_spin, self.joint_scale_z_spin]))
if hasattr(self, 'joint_scale_y_spin'):
self.joint_scale_y_spin.valueChanged.connect(lambda val: utils_rigging.handle_joint_scale_changed(1, [self.joint_scale_x_spin, self.joint_scale_y_spin, self.joint_scale_z_spin]))
if hasattr(self, 'joint_scale_z_spin'):
self.joint_scale_z_spin.valueChanged.connect(lambda val: utils_rigging.handle_joint_scale_changed(2, [self.joint_scale_x_spin, self.joint_scale_y_spin, self.joint_scale_z_spin]))
# 关节属性应用和重置按钮
if "apply_joint_props_btn" in self.buttons:
pos_widgets = [self.joint_pos_x_spin, self.joint_pos_y_spin, self.joint_pos_z_spin] if all(hasattr(self, attr) for attr in ['joint_pos_x_spin', 'joint_pos_y_spin', 'joint_pos_z_spin']) else None
rot_widgets = [self.joint_rot_x_spin, self.joint_rot_y_spin, self.joint_rot_z_spin] if all(hasattr(self, attr) for attr in ['joint_rot_x_spin', 'joint_rot_y_spin', 'joint_rot_z_spin']) else None
scale_widgets = [self.joint_scale_x_spin, self.joint_scale_y_spin, self.joint_scale_z_spin] if all(hasattr(self, attr) for attr in ['joint_scale_x_spin', 'joint_scale_y_spin', 'joint_scale_z_spin']) else None
self.buttons["apply_joint_props_btn"].clicked.connect(lambda: utils_rigging.apply_joint_properties_from_ui(pos_widgets, rot_widgets, scale_widgets))
if "reset_joint_props_btn" in self.buttons:
pos_widgets = [self.joint_pos_x_spin, self.joint_pos_y_spin, self.joint_pos_z_spin] if all(hasattr(self, attr) for attr in ['joint_pos_x_spin', 'joint_pos_y_spin', 'joint_pos_z_spin']) else None
rot_widgets = [self.joint_rot_x_spin, self.joint_rot_y_spin, self.joint_rot_z_spin] if all(hasattr(self, attr) for attr in ['joint_rot_x_spin', 'joint_rot_y_spin', 'joint_rot_z_spin']) else None
scale_widgets = [self.joint_scale_x_spin, self.joint_scale_y_spin, self.joint_scale_z_spin] if all(hasattr(self, attr) for attr in ['joint_scale_x_spin', 'joint_scale_y_spin', 'joint_scale_z_spin']) else None
self.buttons["reset_joint_props_btn"].clicked.connect(lambda: utils_rigging.reset_joint_properties_ui(pos_widgets, rot_widgets, scale_widgets))
# 使用Maya的脚本任务来监听选择变化
ui_utils.connect_maya_selection_changed(self, utils_rigging.on_selection_changed)
# 连接Maya选择变化事
ui_utils.connect_maya_selection_changed(self, lambda: utils_rigging.on_selection_changed(self), self.main_widget)