From d32993b903c9114a24e28419ff4582f08f17c8a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=A8=AA?= <2938139566@qq.com> Date: Thu, 25 Sep 2025 17:51:46 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=90=88=E5=B9=B6=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/assembly_interaction.py | 11 +++-- scene/scene_manager.py | 2 +- ui/main_window.py | 80 +++++++++++++++++++++++++++++++++++- 3 files changed, 88 insertions(+), 5 deletions(-) diff --git a/core/assembly_interaction.py b/core/assembly_interaction.py index c58caafb..3d1c9417 100644 --- a/core/assembly_interaction.py +++ b/core/assembly_interaction.py @@ -640,7 +640,12 @@ class AssemblyInteractionManager(DirectObject): if self.step_dialog: self.step_dialog.close() - self.step_dialog = StepGuideDialog(self) + # 获取主窗口作为父窗口 + parent_window = None + if hasattr(self.world, 'main_window') and self.world.main_window: + parent_window = self.world.main_window + + self.step_dialog = StepGuideDialog(self, parent_window) self.step_dialog.show() def start_current_step(self): @@ -1573,8 +1578,8 @@ class AssemblyInteractionManager(DirectObject): class StepGuideDialog(QDialog): """步骤指引对话框(UI代码保持不变)""" - def __init__(self, interaction_manager): - super().__init__() + def __init__(self, interaction_manager, parent=None): + super().__init__(parent) self.interaction_manager = interaction_manager self.current_required_tool = "无" # 当前步骤要求的工具 self.mode = interaction_manager.mode # 获取模式 diff --git a/scene/scene_manager.py b/scene/scene_manager.py index 37ee239a..f064e7cf 100644 --- a/scene/scene_manager.py +++ b/scene/scene_manager.py @@ -1995,7 +1995,7 @@ class SceneManager: new_element = gui_manager.createGUI2DImage( pos=tuple(absolute_position), image_path=image_path, - size=scale_value * 0.2 + size=scale_value * 0.1 ) elif gui_type == "3d_text" and hasattr(gui_manager, 'createGUI3DText'): size = absolute_scale[0] if absolute_scale and len(absolute_scale) > 0 else 0.5 diff --git a/ui/main_window.py b/ui/main_window.py index 7e5f5739..addf2aa3 100644 --- a/ui/main_window.py +++ b/ui/main_window.py @@ -28,7 +28,7 @@ try: WEB_ENGINE_AVAILABLE = True except ImportError: QWebEngineView = None - WEB_ENGINE_AVAILABLE = False + WEB_ENGINE_AVAILABLE = False class MainWindow(QMainWindow): """主窗口类""" @@ -720,6 +720,9 @@ class MainWindow(QMainWindow): self.interactionMenu.addSeparator() self.startAssemblyInteractionAction = self.interactionMenu.addAction('开始拆装交互') self.startAssemblyInteractionAction.triggered.connect(self.onStartAssemblyInteraction) + self.interactionMenu.addSeparator() + self.maintenanceSystemAction = self.interactionMenu.addAction('🔧 维修系统') + self.maintenanceSystemAction.triggered.connect(self.onOpenMaintenanceSystem) self.cesiumMenu = menubar.addMenu('Cesium') self.loadCesiumTilesetAction = self.cesiumMenu.addAction('加载3Dtiles') @@ -3236,6 +3239,16 @@ class MainWindow(QMainWindow): try: print("🔄 正在关闭应用程序...") + # 关闭拆装交互相关的弹窗 + if hasattr(self.world, 'assembly_interaction') and self.world.assembly_interaction: + print("🧹 关闭拆装交互弹窗...") + if hasattr(self.world.assembly_interaction, 'step_dialog') and self.world.assembly_interaction.step_dialog: + self.world.assembly_interaction.step_dialog.close() + self.world.assembly_interaction.step_dialog = None + # 停止交互模式 + if self.world.assembly_interaction.is_active: + self.world.assembly_interaction.stop_interaction_mode() + # 清理工具管理器中的进程 if hasattr(self.world, 'tool_manager') and self.world.tool_manager: print("🧹 清理工具管理器进程...") @@ -3469,6 +3482,71 @@ class MainWindow(QMainWindow): import traceback traceback.print_exc() + def onOpenMaintenanceSystem(self): + """打开维修系统""" + try: + # 导入简化的登录界面 + from ui.simple_maintenance_login import SimpleMaintenanceLoginDialog + from ui.maintenance_system import MaintenanceSubjectDialog, MaintenanceSystemManager + + print("🔧 启动维修系统...") + + # 显示登录界面 + login_dialog = SimpleMaintenanceLoginDialog(self) + + if login_dialog.exec_() == QDialog.Accepted: + print("✅ 登录成功,显示科目选择界面") + + # 获取当前项目路径 + project_path = None + if hasattr(self.world, 'project_manager') and self.world.project_manager: + project_path = self.world.project_manager.getCurrentProjectPath() + + # 显示科目选择界面 + subject_dialog = MaintenanceSubjectDialog(project_path, self) + + def on_subject_selected(subject_path, mode): + """处理科目选择""" + try: + print(f"🎯 启动维修科目: {subject_path}") + print(f"📝 模式: {mode}") + + # 加载科目配置 + import json + with open(subject_path, 'r', encoding='utf-8') as f: + subject_config = json.load(f) + + # 启动拆装交互系统 + if hasattr(self.world, 'assembly_interaction') and self.world.assembly_interaction: + # 设置配置 + self.world.assembly_interaction.config_data = subject_config + + # 启动交互模式 + self.world.assembly_interaction.start_interaction_mode(mode=mode) + + print(f"✅ 维修科目启动成功") + else: + print("❌ 错误:拆装交互系统未初始化") + QMessageBox.warning(self, "错误", "拆装交互系统未初始化") + + except Exception as e: + print(f"❌ 启动维修科目失败: {e}") + QMessageBox.critical(self, "错误", f"启动维修科目失败:\n{str(e)}") + import traceback + traceback.print_exc() + + subject_dialog.subject_selected.connect(on_subject_selected) + subject_dialog.exec_() + + else: + print("ℹ️ 用户取消了登录") + + except Exception as e: + print(f"❌ 打开维修系统失败: {e}") + QMessageBox.critical(self, "错误", f"打开维修系统失败:\n{str(e)}") + import traceback + traceback.print_exc() + class AssemblyModeSelectionDialog(QDialog): """拆装模式选择对话框"""