Files
bim_engine/src/managers/section-box-dialog-manager.ts

145 lines
4.1 KiB
TypeScript
Raw Normal View History

/**
*
*
*/
import { BaseDialogManager } from '../core/base-dialog-manager';
2025-12-24 19:02:34 +08:00
import { SectionBoxPanel } from '../components/section-box-panel';
import type { SectionBoxRange } from '../components/section-box-panel/types';
/**
*
* BaseDialogManager
2025-12-24 19:02:34 +08:00
*/
export class SectionBoxDialogManager extends BaseDialogManager {
/** 剖切盒面板实例 */
2025-12-24 19:02:34 +08:00
private panel: SectionBoxPanel | null = null;
/** 对话框唯一标识 */
protected get dialogId(): string {
return 'section-box-dialog';
2025-12-24 19:02:34 +08:00
}
/** 对话框标题(国际化 key */
protected get dialogTitle(): string {
return 'sectionBox.dialogTitle';
}
/** 对话框宽度 */
protected get dialogWidth(): number {
return 280;
2025-12-24 19:02:34 +08:00
}
/**
*
*
2025-12-24 19:02:34 +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
const containerWidth = container.clientWidth;
const containerHeight = container.clientHeight;
const paddingRight = 20;
const paddingBottom = 50;
2025-12-24 19:02:34 +08:00
return {
x: containerWidth - this.dialogWidth - paddingRight,
y: containerHeight - paddingBottom - 300
};
}
/**
*
*
*/
protected createContent(): HTMLElement {
2025-12-24 19:02:34 +08:00
this.panel = new SectionBoxPanel({
defaultHidden: false,
defaultReversed: false,
onHideToggle: (isHidden) => {
console.log('[SectionBoxDialogManager] 隐藏切换:', isHidden);
},
onReverseToggle: (isReversed) => {
console.log('[SectionBoxDialogManager] 反向切换:', isReversed);
},
onFitToModel: () => {
console.log('[SectionBoxDialogManager] 适应到模型');
},
onReset: () => {
console.log('[SectionBoxDialogManager] 重置');
},
onRangeChange: (range) => {
console.log('[SectionBoxDialogManager] 范围变化:', range);
}
});
this.panel.init();
return this.panel.element;
}
2025-12-24 19:02:34 +08:00
/** 对话框创建后的回调,自适应高度 */
protected onDialogCreated(): void {
this.dialog?.fitHeight(false);
}
2025-12-24 19:02:34 +08:00
/** 对话框关闭时的回调,取消工具栏按钮激活状态 */
protected onDialogClose(): void {
this.registry.toolbar?.setBtnActive('section-box', false);
2025-12-24 19:02:34 +08:00
}
/** 销毁前的清理,销毁面板实例 */
protected onBeforeDestroy(): void {
if (this.panel) {
this.panel.destroy();
this.panel = null;
}
2025-12-24 19:02:34 +08:00
}
/**
*
* @returns
2025-12-24 19:02:34 +08:00
*/
public getHiddenState(): boolean {
return this.panel?.getHiddenState() ?? false;
}
/**
*
* @param isHidden
2025-12-24 19:02:34 +08:00
*/
public setHiddenState(isHidden: boolean): void {
this.panel?.setHiddenState(isHidden);
}
/**
*
* @returns /
2025-12-24 19:02:34 +08:00
*/
public getReversedState(): boolean {
return this.panel?.getReversedState() ?? false;
}
/**
*
* @param isReversed
2025-12-24 19:02:34 +08:00
*/
public setReversedState(isReversed: boolean): void {
this.panel?.setReversedState(isReversed);
}
/**
*
* @returns { minX, maxX, minY, maxY, minZ, maxZ }
2025-12-24 19:02:34 +08:00
*/
public getRange(): SectionBoxRange | null {
return this.panel?.getRange() ?? null;
}
/**
*
* @param range
2025-12-24 19:02:34 +08:00
*/
public setRange(range: Partial<SectionBoxRange>): void {
this.panel?.setRange(range);
}
}