2026-01-22 15:23:57 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 轴向剖切对话框管理器
|
|
|
|
|
|
* 负责管理轴向剖切工具对话框的显示、隐藏和剖切面板的交互
|
|
|
|
|
|
*/
|
|
|
|
|
|
import { BaseDialogManager } from '../core/base-dialog-manager';
|
2025-12-24 19:02:34 +08:00
|
|
|
|
import { SectionAxisPanel } from '../components/section-axis-panel';
|
|
|
|
|
|
import type { SectionAxis } from '../components/section-axis-panel/types';
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2026-01-22 15:23:57 +08:00
|
|
|
|
* 轴向剖切对话框管理器
|
|
|
|
|
|
* 继承自 BaseDialogManager,提供 X/Y/Z 轴向剖切的对话框管理功能
|
2025-12-24 19:02:34 +08:00
|
|
|
|
*/
|
2026-01-22 15:23:57 +08:00
|
|
|
|
export class SectionAxisDialogManager extends BaseDialogManager {
|
|
|
|
|
|
/** 轴向剖切面板实例 */
|
2025-12-24 19:02:34 +08:00
|
|
|
|
private panel: SectionAxisPanel | null = null;
|
|
|
|
|
|
|
2026-01-22 15:23:57 +08:00
|
|
|
|
/** 对话框唯一标识 */
|
|
|
|
|
|
protected get dialogId(): string {
|
|
|
|
|
|
return 'section-axis-dialog';
|
2025-12-24 19:02:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-22 15:23:57 +08:00
|
|
|
|
/** 对话框标题(国际化 key) */
|
|
|
|
|
|
protected get dialogTitle(): string {
|
|
|
|
|
|
return 'sectionAxis.dialogTitle';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** 对话框宽度 */
|
|
|
|
|
|
protected get dialogWidth(): number {
|
|
|
|
|
|
return 240;
|
2025-12-24 19:02:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2026-01-22 15:23:57 +08:00
|
|
|
|
* 获取对话框位置
|
|
|
|
|
|
* 定位在容器右下角
|
2025-12-24 19:02:34 +08:00
|
|
|
|
*/
|
2026-01-22 15:23:57 +08:00
|
|
|
|
protected getDialogPosition(): { x: number; y: number } {
|
|
|
|
|
|
const container = this.registry.container;
|
|
|
|
|
|
if (!container) return { x: 100, y: 100 };
|
2025-12-24 19:02:34 +08:00
|
|
|
|
|
2026-01-22 15:23:57 +08:00
|
|
|
|
const containerWidth = container.clientWidth;
|
|
|
|
|
|
const containerHeight = container.clientHeight;
|
|
|
|
|
|
const paddingRight = 20;
|
|
|
|
|
|
const paddingBottom = 50;
|
2025-12-24 19:02:34 +08:00
|
|
|
|
|
2026-01-22 15:23:57 +08:00
|
|
|
|
return {
|
|
|
|
|
|
x: containerWidth - this.dialogWidth - paddingRight,
|
|
|
|
|
|
y: containerHeight - paddingBottom - 200
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 创建对话框内容
|
|
|
|
|
|
* 初始化轴向剖切面板并设置回调
|
|
|
|
|
|
*/
|
|
|
|
|
|
protected createContent(): HTMLElement {
|
2025-12-24 19:02:34 +08:00
|
|
|
|
this.panel = new SectionAxisPanel({
|
|
|
|
|
|
defaultAxis: 'x',
|
|
|
|
|
|
defaultHidden: false,
|
|
|
|
|
|
onHideToggle: (isHidden) => {
|
2026-02-02 16:36:17 +08:00
|
|
|
|
console.log('[SectionAxisDialogManager] 隐藏切换:', isHidden);
|
|
|
|
|
|
if (isHidden) {
|
|
|
|
|
|
this.registry.engine3d?.hideSection();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.registry.engine3d?.recoverSection();
|
|
|
|
|
|
}
|
2025-12-24 19:02:34 +08:00
|
|
|
|
},
|
|
|
|
|
|
onReverse: () => {
|
2026-01-27 17:59:52 +08:00
|
|
|
|
// 反向功能:第三方引擎无 API,仅输出日志
|
|
|
|
|
|
console.log('[SectionAxisDialogManager] 反向剖切(暂不支持)');
|
2025-12-24 19:02:34 +08:00
|
|
|
|
},
|
|
|
|
|
|
onAxisChange: (axis) => {
|
|
|
|
|
|
console.log('[SectionAxisDialogManager] 切换轴向:', axis);
|
2026-02-02 16:25:32 +08:00
|
|
|
|
this.registry.engine3d?.activeSection(axis);
|
2025-12-24 19:02:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
this.panel.init();
|
2026-01-22 15:23:57 +08:00
|
|
|
|
return this.panel.element;
|
|
|
|
|
|
}
|
2025-12-24 19:02:34 +08:00
|
|
|
|
|
2026-01-22 15:23:57 +08:00
|
|
|
|
/** 对话框创建后的回调,自适应高度 */
|
|
|
|
|
|
protected onDialogCreated(): void {
|
|
|
|
|
|
this.dialog?.fitHeight(false);
|
2026-01-27 17:59:52 +08:00
|
|
|
|
|
|
|
|
|
|
// 检查 Engine 是否已初始化
|
|
|
|
|
|
if (!this.registry.engine3d) {
|
|
|
|
|
|
console.error('[SectionAxisDialogManager] Engine not initialized. Call initEngine() first.');
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 自动激活默认轴向剖切(X轴)
|
2026-02-02 16:25:32 +08:00
|
|
|
|
this.registry.engine3d.activeSection('x');
|
2026-01-22 15:23:57 +08:00
|
|
|
|
}
|
2025-12-24 19:02:34 +08:00
|
|
|
|
|
2026-01-22 15:23:57 +08:00
|
|
|
|
/** 对话框关闭时的回调,取消工具栏按钮激活状态 */
|
|
|
|
|
|
protected onDialogClose(): void {
|
|
|
|
|
|
this.registry.toolbar?.setBtnActive('section-axis', false);
|
2025-12-24 19:02:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-22 15:23:57 +08:00
|
|
|
|
/** 销毁前的清理,销毁面板实例 */
|
|
|
|
|
|
protected onBeforeDestroy(): void {
|
2026-02-02 16:25:32 +08:00
|
|
|
|
this.registry.engine3d?.deactivateSection();
|
2026-01-27 17:59:52 +08:00
|
|
|
|
|
2026-01-22 15:23:57 +08:00
|
|
|
|
if (this.panel) {
|
|
|
|
|
|
this.panel.destroy();
|
|
|
|
|
|
this.panel = null;
|
|
|
|
|
|
}
|
2025-12-24 19:02:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2026-01-22 15:23:57 +08:00
|
|
|
|
* 获取剖切面隐藏状态
|
|
|
|
|
|
* @returns 是否隐藏
|
2025-12-24 19:02:34 +08:00
|
|
|
|
*/
|
|
|
|
|
|
public getHiddenState(): boolean {
|
|
|
|
|
|
return this.panel?.getHiddenState() ?? false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2026-01-22 15:23:57 +08:00
|
|
|
|
* 设置剖切面隐藏状态
|
|
|
|
|
|
* @param isHidden 是否隐藏
|
2025-12-24 19:02:34 +08:00
|
|
|
|
*/
|
|
|
|
|
|
public setHiddenState(isHidden: boolean): void {
|
|
|
|
|
|
this.panel?.setHiddenState(isHidden);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2026-01-22 15:23:57 +08:00
|
|
|
|
* 获取当前激活的剖切轴向
|
|
|
|
|
|
* @returns 当前轴向 'x' | 'y' | 'z'
|
2025-12-24 19:02:34 +08:00
|
|
|
|
*/
|
|
|
|
|
|
public getActiveAxis(): SectionAxis {
|
|
|
|
|
|
return this.panel?.getActiveAxis() ?? 'x';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2026-01-22 15:23:57 +08:00
|
|
|
|
* 设置剖切轴向
|
|
|
|
|
|
* @param axis 目标轴向
|
2025-12-24 19:02:34 +08:00
|
|
|
|
*/
|
|
|
|
|
|
public setActiveAxis(axis: SectionAxis): void {
|
|
|
|
|
|
this.panel?.setActiveAxis(axis);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|