update
This commit is contained in:
parent
643ba521d8
commit
5ee392002e
@ -39,14 +39,19 @@ from scripts.ui.widgets import ModernTabWidget
|
|||||||
class MainWindow(QtWidgets.QMainWindow):
|
class MainWindow(QtWidgets.QMainWindow):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super(MainWindow, self).__init__(parent)
|
super(MainWindow, self).__init__(parent)
|
||||||
|
|
||||||
|
# 设置窗口属性
|
||||||
|
self.setWindowFlags(QtCore.Qt.Window)
|
||||||
|
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
||||||
|
|
||||||
# 设置基础字体大小
|
# 设置基础字体大小
|
||||||
font = self.font()
|
font = self.font()
|
||||||
font.setPointSize(9) # 设置基础字号
|
font.setPointSize(9)
|
||||||
self.setFont(font)
|
self.setFont(font)
|
||||||
|
|
||||||
# 设置窗口大小
|
# 设置窗口尺寸
|
||||||
self.resize(700, 600) # 调整为更合适的尺寸
|
self.resize(550, 700) # 调整为更大的初始尺寸
|
||||||
self.setMinimumSize(700, 500)
|
self.setMinimumSize(550, 700) # 设置最小尺寸限制
|
||||||
|
|
||||||
self.setup_core_components()
|
self.setup_core_components()
|
||||||
|
|
||||||
@ -130,9 +135,19 @@ def dock_to_maya():
|
|||||||
data.TOOL_WSCL_NAME,
|
data.TOOL_WSCL_NAME,
|
||||||
label=data.TOOL_NAME,
|
label=data.TOOL_NAME,
|
||||||
tabToControl=["AttributeEditor", -1],
|
tabToControl=["AttributeEditor", -1],
|
||||||
initialWidth=1400,
|
initialWidth=550,
|
||||||
minimumWidth=1000,
|
initialHeight=700,
|
||||||
minimumHeight=800
|
minimumWidth=550,
|
||||||
|
minimumHeight=700,
|
||||||
|
floating=True, # 设置为悬浮状态
|
||||||
|
retain=False # 不保存上次的停靠状态
|
||||||
|
)
|
||||||
|
|
||||||
|
# 确保窗口显示在合适的位置
|
||||||
|
cmds.workspaceControl(
|
||||||
|
data.TOOL_WSCL_NAME,
|
||||||
|
e=True,
|
||||||
|
restore=True
|
||||||
)
|
)
|
||||||
|
|
||||||
maya_dock_ptr = omui.MQtUtil.findControl(dock_control)
|
maya_dock_ptr = omui.MQtUtil.findControl(dock_control)
|
||||||
|
@ -5,18 +5,18 @@ from typing import Dict, List
|
|||||||
@dataclass
|
@dataclass
|
||||||
class Point3:
|
class Point3:
|
||||||
"""
|
"""
|
||||||
A model class for representing a 3 dimensional point
|
表示三维空间中的点的模型类
|
||||||
|
|
||||||
Attributes
|
属性
|
||||||
----------
|
----------
|
||||||
@type x: float
|
@type x: float
|
||||||
@param x: The value of x
|
@param x: x坐标值
|
||||||
|
|
||||||
@type y: float
|
@type y: float
|
||||||
@param y: The value of y
|
@param y: y坐标值
|
||||||
|
|
||||||
@type z: float
|
@type z: float
|
||||||
@param z: The value of z
|
@param z: z坐标值
|
||||||
"""
|
"""
|
||||||
|
|
||||||
x: float = field(default=0.0)
|
x: float = field(default=0.0)
|
||||||
@ -27,15 +27,15 @@ class Point3:
|
|||||||
@dataclass
|
@dataclass
|
||||||
class UV:
|
class UV:
|
||||||
"""
|
"""
|
||||||
A model class for holding data about the UV
|
用于保存UV数据的模型类
|
||||||
|
|
||||||
Attributes
|
属性
|
||||||
----------
|
----------
|
||||||
@type u: float
|
@type u: float
|
||||||
@param u: The value of u
|
@param u: u坐标值
|
||||||
|
|
||||||
@type v: float
|
@type v: float
|
||||||
@param v: The value of v
|
@param v: v坐标值
|
||||||
"""
|
"""
|
||||||
|
|
||||||
u: float = field(default=0.0)
|
u: float = field(default=0.0)
|
||||||
@ -45,15 +45,15 @@ class UV:
|
|||||||
@dataclass
|
@dataclass
|
||||||
class Layout:
|
class Layout:
|
||||||
"""
|
"""
|
||||||
A model class for holding data about a single layout
|
用于保存单个Layout数据的模型类
|
||||||
|
|
||||||
Attributes
|
属性
|
||||||
----------
|
----------
|
||||||
@type position_index: int
|
@type position_index: int
|
||||||
@param position_index: An index representing position
|
@param position_index: 表示位置的索引
|
||||||
|
|
||||||
@type texture_coordinate_index: int
|
@type texture_coordinate_index: int
|
||||||
@param texture_coordinate_index: A value representing the texture coordinate index
|
@param texture_coordinate_index: 表示纹理坐标的索引值
|
||||||
"""
|
"""
|
||||||
|
|
||||||
position_index: int = field(default=0)
|
position_index: int = field(default=0)
|
||||||
@ -63,21 +63,21 @@ class Layout:
|
|||||||
@dataclass
|
@dataclass
|
||||||
class Topology:
|
class Topology:
|
||||||
"""
|
"""
|
||||||
A model class for holding data about the topology
|
用于保存拓扑数据的模型类
|
||||||
|
|
||||||
Attributes
|
属性
|
||||||
----------
|
----------
|
||||||
@type positions: List[Point3]
|
@type positions: List[Point3]
|
||||||
@param positions: List of points in space representing the positions
|
@param positions: 表示位置的空间点列表
|
||||||
|
|
||||||
@type texture_coordinates: List[UV]
|
@type texture_coordinates: List[UV]
|
||||||
@param texture_coordinates: List of UVs representing the positions
|
@param texture_coordinates: 表示UV位置的列表
|
||||||
|
|
||||||
@type layouts: List[Layout]
|
@type layouts: List[Layout]
|
||||||
@param layouts: The list of Layout mappings
|
@param layouts: Layout映射列表
|
||||||
|
|
||||||
@type face_vertex_layouts: List[List[int]]
|
@type face_vertex_layouts: List[List[int]]
|
||||||
@param face_vertex_layouts: List of face vertex layout indices by face index
|
@param face_vertex_layouts: 按面索引排列的面顶点Layout索引列表
|
||||||
"""
|
"""
|
||||||
|
|
||||||
positions: List[Point3] = field(default_factory=list)
|
positions: List[Point3] = field(default_factory=list)
|
||||||
@ -89,15 +89,15 @@ class Topology:
|
|||||||
@dataclass
|
@dataclass
|
||||||
class BlendShape:
|
class BlendShape:
|
||||||
"""
|
"""
|
||||||
A model class for holding data about the blend shape
|
用于保存BlendShape数据的模型类
|
||||||
|
|
||||||
Attributes
|
属性
|
||||||
----------
|
----------
|
||||||
@type channel: int
|
@type channel: int
|
||||||
@param channel: The index pointing to the blend shape name
|
@param channel: 指向BlendShape名称的索引
|
||||||
|
|
||||||
@type deltas: Dict[int, Point3]
|
@type deltas: Dict[int, Point3]
|
||||||
@param deltas: A mapping of blend shape indices to the coordinate differences that are made by the blend shape
|
@param deltas: BlendShape索引到坐标差值的映射
|
||||||
"""
|
"""
|
||||||
|
|
||||||
channel: int = field(default=None)
|
channel: int = field(default=None)
|
||||||
@ -107,16 +107,15 @@ class BlendShape:
|
|||||||
@dataclass
|
@dataclass
|
||||||
class SkinWeightsData:
|
class SkinWeightsData:
|
||||||
"""
|
"""
|
||||||
A model class for holding data about the skin weights
|
用于保存蒙皮权重数据的模型类
|
||||||
|
|
||||||
Attributes
|
属性
|
||||||
----------
|
----------
|
||||||
|
|
||||||
@type values: List[List[float]]
|
@type values: List[List[float]]
|
||||||
@param values: The skin weight values per vertex index
|
@param values: 每个顶点索引的蒙皮权重值
|
||||||
|
|
||||||
@type joint_indices: List[List[int]]
|
@type joint_indices: List[List[int]]
|
||||||
@param joint_indices: The joint indces per vertex index
|
@param joint_indices: 每个顶点索引的关节索引
|
||||||
"""
|
"""
|
||||||
|
|
||||||
values: List[List[float]] = field(default_factory=list)
|
values: List[List[float]] = field(default_factory=list)
|
||||||
@ -126,21 +125,21 @@ class SkinWeightsData:
|
|||||||
@dataclass
|
@dataclass
|
||||||
class Mesh:
|
class Mesh:
|
||||||
"""
|
"""
|
||||||
A model class for holding data about the mesh
|
用于保存网格数据的模型类
|
||||||
|
|
||||||
Attributes
|
属性
|
||||||
----------
|
----------
|
||||||
@type name: str
|
@type name: str
|
||||||
@param name: The name of the mesh
|
@param name: 网格名称
|
||||||
|
|
||||||
@type topology: Topology
|
@type topology: Topology
|
||||||
@param topology: Data containing the topology of the mesh
|
@param topology: 包含网格拓扑数据
|
||||||
|
|
||||||
@type skin_weights: SkinWeightsData
|
@type skin_weights: SkinWeightsData
|
||||||
@param skin_weights: Data representing skin weights
|
@param skin_weights: 表示蒙皮权重的数据
|
||||||
|
|
||||||
@type blend_shapes: List[BlendShape]
|
@type blend_shapes: List[BlendShape]
|
||||||
@param blend_shapes: The list of blend shapes for the mesh
|
@param blend_shapes: 网格的BlendShape列表
|
||||||
"""
|
"""
|
||||||
|
|
||||||
name: str = field(default=None)
|
name: str = field(default=None)
|
||||||
@ -152,21 +151,21 @@ class Mesh:
|
|||||||
@dataclass
|
@dataclass
|
||||||
class Joint:
|
class Joint:
|
||||||
"""
|
"""
|
||||||
A model class for holding data about a single joint
|
用于保存单个关节数据的模型类
|
||||||
|
|
||||||
Attributes
|
属性
|
||||||
----------
|
----------
|
||||||
@type name: str
|
@type name: str
|
||||||
@param name: The name of the joint
|
@param name: 关节名称
|
||||||
|
|
||||||
@type translation: Point3
|
@type translation: Point3
|
||||||
@param translation: A point in 3 dimensional space which represents the translation of the joint
|
@param translation: 表示关节位移的三维空间点
|
||||||
|
|
||||||
@type orientation: Point3
|
@type orientation: Point3
|
||||||
@param orientation: A point in 3 dimensional space which represents the orientation of the joint
|
@param orientation: 表示关节方向的三维空间点
|
||||||
|
|
||||||
@type parent_name: str
|
@type parent_name: str
|
||||||
@param parent_name: The name of the parent joint
|
@param parent_name: 父关节名称
|
||||||
"""
|
"""
|
||||||
|
|
||||||
name: str = field(default=None)
|
name: str = field(default=None)
|
||||||
|
@ -111,22 +111,23 @@ class MenuManager:
|
|||||||
def _create_toolbar(self):
|
def _create_toolbar(self):
|
||||||
"""创建工具栏"""
|
"""创建工具栏"""
|
||||||
toolbar = self.parent.addToolBar("主工具栏")
|
toolbar = self.parent.addToolBar("主工具栏")
|
||||||
toolbar.setMovable(True) # 允许移动
|
toolbar.setMovable(True)
|
||||||
toolbar.setFloatable(True) # 允许浮动
|
toolbar.setFloatable(True)
|
||||||
|
toolbar.setIconSize(QtCore.QSize(24, 24))
|
||||||
|
|
||||||
# 定义工具栏按钮
|
# 定义工具栏按钮 (text, icon, callback, tooltip)
|
||||||
toolbar_items = [
|
toolbar_items = [
|
||||||
("保存DNA", "save.png", menu_utils.save_dna),
|
("保存DNA", "save.png", menu_utils.save_dna, "保存DNA"),
|
||||||
("加载当前项目DNA", "open.png", menu_utils.load_project_dna),
|
("加载当前项目DNA", "open.png", menu_utils.load_dna, "加载DNA"),
|
||||||
None,
|
None,
|
||||||
("创建RL4节点", "connect.png", adjust_utils.create_rl4_node),
|
("创建RL4节点", "connect.png", adjust_utils.create_rl4_node, "连接表情控制"),
|
||||||
("删除RL4节点", "disconnect.png", adjust_utils.delete_rl4_node),
|
("删除RL4节点", "disconnect.png", adjust_utils.delete_rl4_node, "断开表情控制"),
|
||||||
None,
|
None,
|
||||||
("导入FBX蒙皮", "export_skin.png", rigging_utils.import_skin),
|
("导入FBX蒙皮", "import_skin.png", rigging_utils.import_skin, "导入蒙皮"),
|
||||||
("导出FBX蒙皮", "export_skin.png", rigging_utils.export_skin),
|
("导出FBX蒙皮", "export_skin.png", rigging_utils.export_skin, "导出蒙皮"),
|
||||||
None,
|
None,
|
||||||
("帮助文档", "help.png", menu_utils.show_help),
|
("帮助文档", "help.png", menu_utils.show_help, "帮助文档"),
|
||||||
("关于", "warning.png", menu_utils.show_about)
|
("关于", "warning.png", menu_utils.show_about, "关于MetaFusion")
|
||||||
]
|
]
|
||||||
|
|
||||||
self._add_toolbar_items(toolbar, toolbar_items)
|
self._add_toolbar_items(toolbar, toolbar_items)
|
||||||
@ -152,11 +153,12 @@ class MenuManager:
|
|||||||
if item is None:
|
if item is None:
|
||||||
toolbar.addSeparator()
|
toolbar.addSeparator()
|
||||||
else:
|
else:
|
||||||
text, icon, callback = item
|
text, icon, callback, tooltip = item # 现在解包4个值
|
||||||
action = QtWidgets.QAction(text, self.parent)
|
action = QtWidgets.QAction(text, self.parent)
|
||||||
if icon:
|
if icon:
|
||||||
icon_path = os.path.join(data.ICONS_PATH, icon)
|
icon_path = os.path.join(data.ICONS_PATH, icon)
|
||||||
if os.path.exists(icon_path):
|
if os.path.exists(icon_path):
|
||||||
action.setIcon(QtGui.QIcon(icon_path))
|
action.setIcon(QtGui.QIcon(icon_path))
|
||||||
|
action.setToolTip(tooltip) # 设置工具提示
|
||||||
action.triggered.connect(lambda checked=False, fn=callback: fn())
|
action.triggered.connect(lambda checked=False, fn=callback: fn())
|
||||||
toolbar.addAction(action)
|
toolbar.addAction(action)
|
Loading…
Reference in New Issue
Block a user