初始化
This commit is contained in:
97
src/managers/walk-plan-view-dialog-manager.ts
Normal file
97
src/managers/walk-plan-view-dialog-manager.ts
Normal file
@@ -0,0 +1,97 @@
|
||||
import { BimComponent } from '../core/component';
|
||||
import { BimEngine } from '../bim-engine';
|
||||
import { BimDialog } from '../components/dialog';
|
||||
import { WalkPlanViewPanel } from '../components/walk-plan-view-panel';
|
||||
|
||||
/**
|
||||
* 平面图弹窗管理器
|
||||
*/
|
||||
export class WalkPlanViewDialogManager extends BimComponent {
|
||||
private dialogId = 'walk-plan-view-dialog';
|
||||
private dialog: BimDialog | null = null;
|
||||
private panel: WalkPlanViewPanel | null = null;
|
||||
|
||||
constructor(engine: BimEngine) {
|
||||
super(engine);
|
||||
}
|
||||
|
||||
public init(): void {
|
||||
// 可以在这里监听事件
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示弹窗
|
||||
*/
|
||||
public show(): void {
|
||||
if (!this.engine.dialog || !this.engine.container) {
|
||||
console.warn('Dialog manager or container is not initialized');
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果已打开,先销毁
|
||||
this.destroy();
|
||||
|
||||
// 创建面板(暂时空内容)
|
||||
this.panel = new WalkPlanViewPanel();
|
||||
this.panel.init();
|
||||
|
||||
const dialogWidth = 300;
|
||||
const dialogHeight = 400;
|
||||
const paddingLeft = 20;
|
||||
const paddingBottom = 20;
|
||||
const container = this.engine.container;
|
||||
const containerHeight = container.clientHeight;
|
||||
|
||||
// 左下角:left: 20px, bottom: 20px
|
||||
const x = paddingLeft;
|
||||
const y = containerHeight - dialogHeight - paddingBottom;
|
||||
|
||||
this.dialog = this.engine.dialog.create({
|
||||
id: this.dialogId,
|
||||
title: 'walkControl.planView.dialogTitle',
|
||||
width: dialogWidth,
|
||||
height: dialogHeight,
|
||||
position: { x, y },
|
||||
draggable: true,
|
||||
resizable: false,
|
||||
content: this.panel.element,
|
||||
onClose: () => {
|
||||
// 通知主控制面板更新状态
|
||||
if (this.engine.walkControl && this.engine.walkControl.panel) {
|
||||
this.engine.walkControl.panel.setPlanViewActive(false);
|
||||
}
|
||||
this.hide();
|
||||
}
|
||||
});
|
||||
this.dialog.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏弹窗
|
||||
*/
|
||||
public hide(): void {
|
||||
this.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 销毁弹窗和面板
|
||||
*/
|
||||
public destroy(): void {
|
||||
// 先保存 dialog 引用,避免在回调中重复调用
|
||||
const dialog = this.dialog;
|
||||
|
||||
// 立即清空引用,防止递归
|
||||
this.dialog = null;
|
||||
|
||||
// 关闭弹窗
|
||||
if (dialog) {
|
||||
dialog.destroy();
|
||||
}
|
||||
|
||||
// 销毁面板
|
||||
if (this.panel) {
|
||||
this.panel.destroy();
|
||||
this.panel = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user