Files
bim_engine/src/core/manager-registry.ts
yuding 837177f3f2 feat: add settings dialog with render mode selection
- Add SettingDialogManager with radio-style render mode picker (simple/balance/advanced)
- Add getRenderMode/setRenderMode API to Engine and EngineManager layers
- Wire setting toolbar button to toggle the settings dialog
- Add i18n keys for settings dialog (zh-CN/en-US)
- Add version display at bottom-right of engine wrapper
- Bump version to 1.1.7, rebuild and sync demo libs
2026-02-28 11:26:59 +08:00

141 lines
5.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Manager 注册表
* 每个 BimEngine 实例持有独立的 Registry实现多实例隔离
*/
import { EventEmitter } from './event-emitter';
import type { EngineEvents } from '../types/events';
import type { ToolbarManager } from '../managers/toolbar-manager';
import type { DialogManager } from '../managers/dialog-manager';
import type { EngineManager } from '../managers/engine-manager';
import type { ButtonGroupManager } from '../managers/button-group-manager';
import type { RightKeyManager } from '../managers/right-key-manager';
import type { ConstructTreeManagerBtn } from '../managers/construct-tree-manager-btn';
import type { MeasureDialogManager } from '../managers/measure-dialog-manager';
import type { WalkControlManager } from '../managers/walk-control-manager';
import type { SectionPlaneDialogManager } from '../managers/section-plane-dialog-manager';
import type { SectionAxisDialogManager } from '../managers/section-axis-dialog-manager';
import type { SectionBoxDialogManager } from '../managers/section-box-dialog-manager';
import type { WalkPathDialogManager } from '../managers/walk-path-dialog-manager';
import type { WalkPlanViewDialogManager } from '../managers/walk-plan-view-dialog-manager';
import type { EngineInfoDialogManager } from '../managers/engine-info-dialog-manager';
import type { SettingDialogManager } from '../managers/setting-dialog-manager';
import type { ComponentDetailManager } from '../managers/component-detail-manager';
import type { AiChatManager } from '../managers/ai-chat-manager';
/**
* Manager 注册表 - 实例模式
* 每个 BimEngine 创建独立的 Registry 实例,替代旧的全局单例
*/
export class ManagerRegistry {
/** 事件发射器 */
private eventEmitter: EventEmitter = new EventEmitter();
/** 主容器元素 */
public container: HTMLElement | null = null;
/** 包装容器元素 */
public wrapper: HTMLElement | null = null;
/** 工具栏管理器 */
public toolbar: ToolbarManager | null = null;
/** 对话框管理器 */
public dialog: DialogManager | null = null;
/** 3D 引擎管理器 */
public engine3d: EngineManager | null = null;
/** 按钮组管理器 */
public buttonGroup: ButtonGroupManager | null = null;
/** 右键菜单管理器 */
public rightKey: RightKeyManager | null = null;
/** 构件树管理器 */
public constructTree: ConstructTreeManagerBtn | null = null;
/** 测量对话框管理器 */
public measure: MeasureDialogManager | null = null;
/** 漫游控制管理器 */
public walkControl: WalkControlManager | null = null;
/** 拾取面剖切对话框管理器 */
public sectionPlane: SectionPlaneDialogManager | null = null;
/** 轴向剖切对话框管理器 */
public sectionAxis: SectionAxisDialogManager | null = null;
/** 剖切盒对话框管理器 */
public sectionBox: SectionBoxDialogManager | null = null;
/** 漫游路径对话框管理器 */
public walkPath: WalkPathDialogManager | null = null;
/** 漫游平面图对话框管理器 */
public walkPlanView: WalkPlanViewDialogManager | null = null;
/** 引擎信息对话框管理器 */
public engineInfo: EngineInfoDialogManager | null = null;
/** 构件详情管理器 */
public componentDetail: ComponentDetailManager | null = null;
/** AI 聊天管理器 */
public aiChat: AiChatManager | null = null;
/** 设置对话框管理器 */
public setting: SettingDialogManager | null = null;
constructor() {}
/** 重置(清理事件和引用) */
public reset(): void {
this.eventEmitter.clear();
this.container = null;
this.wrapper = null;
this.toolbar = null;
this.dialog = null;
this.engine3d = null;
this.buttonGroup = null;
this.rightKey = null;
this.constructTree = null;
this.measure = null;
this.walkControl = null;
this.sectionPlane = null;
this.sectionAxis = null;
this.sectionBox = null;
this.walkPath = null;
this.walkPlanView = null;
this.engineInfo = null;
this.componentDetail = null;
this.aiChat = null;
this.setting = null;
}
/**
* 发送事件
* @param event 事件名称
* @param payload 事件数据
*/
public emit<K extends keyof EngineEvents>(event: K, payload: EngineEvents[K]): void {
this.eventEmitter.emit(event, payload);
}
/**
* 订阅事件
* @param event 事件名称
* @param listener 事件处理函数
* @returns 取消订阅的函数
*/
public on<K extends keyof EngineEvents>(
event: K,
listener: (payload: EngineEvents[K]) => void
): () => void {
return this.eventEmitter.on(event, listener);
}
/**
* 取消订阅事件
* @param event 事件名称
* @param listener 事件处理函数
*/
public off<K extends keyof EngineEvents>(
event: K,
listener: (payload: EngineEvents[K]) => void
): void {
this.eventEmitter.off(event, listener);
}
/** 清除所有事件监听器 */
public clearEvents(): void {
this.eventEmitter.clear();
}
}