初始化

This commit is contained in:
yuding
2025-12-24 19:02:34 +08:00
parent 4b5eb78bbb
commit 04a5e74284
51 changed files with 8576 additions and 5334 deletions

View File

@@ -0,0 +1,135 @@
import { BimComponent } from '../core/component';
import { BimEngine } from '../bim-engine';
import { BimDialog } from '../components/dialog';
import { SectionAxisPanel } from '../components/section-axis-panel';
import type { SectionAxis } from '../components/section-axis-panel/types';
/**
* 轴向剖切弹窗管理器
*/
export class SectionAxisDialogManager extends BimComponent {
private dialogId = 'section-axis-dialog';
private dialog: BimDialog | null = null;
private panel: SectionAxisPanel | 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 SectionAxisPanel({
defaultAxis: 'x',
defaultHidden: false,
onHideToggle: (isHidden) => {
console.log('[SectionAxisDialogManager] 隐藏切换:', isHidden);
// TODO: 实现隐藏/显示剖切面的逻辑
},
onReverse: () => {
console.log('[SectionAxisDialogManager] 反向剖切');
// TODO: 实现反向剖切的逻辑
},
onAxisChange: (axis) => {
console.log('[SectionAxisDialogManager] 切换轴向:', axis);
// TODO: 实现轴向切换的逻辑
}
});
this.panel.init();
// 创建弹窗
const dialogWidth = 240;
const paddingRight = 20;
const paddingBottom = 50;
const container = this.engine.container;
const containerWidth = container.clientWidth;
const containerHeight = container.clientHeight;
const x = containerWidth - dialogWidth - paddingRight;
const y = containerHeight - paddingBottom - 200; // 临时y值会被fitHeight调整
this.dialog = this.engine.dialog.create({
id: this.dialogId,
title: 'sectionAxis.dialogTitle',
width: dialogWidth,
height: 'auto', // 自动高度
position: { x, y },
draggable: true,
resizable: false,
content: this.panel.element,
onClose: () => {
this.engine.toolbar?.setBtnActive('section-axis', false);
this.hide();
}
});
this.dialog.init();
// 自适应高度
this.dialog.fitHeight(false);
}
/**
* 隐藏弹窗
*/
public hide(): void {
this.destroy();
}
/**
* 获取隐藏状态
*/
public getHiddenState(): boolean {
return this.panel?.getHiddenState() ?? false;
}
/**
* 设置隐藏状态
*/
public setHiddenState(isHidden: boolean): void {
this.panel?.setHiddenState(isHidden);
}
/**
* 获取当前激活的轴向
*/
public getActiveAxis(): SectionAxis {
return this.panel?.getActiveAxis() ?? 'x';
}
/**
* 设置激活的轴向
*/
public setActiveAxis(axis: SectionAxis): void {
this.panel?.setActiveAxis(axis);
}
/**
* 销毁弹窗和面板
*/
public destroy(): void {
// 关闭弹窗
if (this.dialog) {
this.dialog.destroy();
this.dialog = null;
}
// 销毁面板
if (this.panel) {
this.panel.destroy();
this.panel = null;
}
}
}

View File

@@ -0,0 +1,159 @@
import { BimComponent } from '../core/component';
import { BimEngine } from '../bim-engine';
import { BimDialog } from '../components/dialog';
import { SectionBoxPanel } from '../components/section-box-panel';
import type { SectionBoxRange } from '../components/section-box-panel/types';
/**
* 剖切盒弹窗管理器
*/
export class SectionBoxDialogManager extends BimComponent {
private dialogId = 'section-box-dialog';
private dialog: BimDialog | null = null;
private panel: SectionBoxPanel | 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 SectionBoxPanel({
defaultHidden: false,
defaultReversed: false,
onHideToggle: (isHidden) => {
console.log('[SectionBoxDialogManager] 隐藏切换:', isHidden);
// TODO: 实现隐藏/显示剖切盒的逻辑
},
onReverseToggle: (isReversed) => {
console.log('[SectionBoxDialogManager] 反向切换:', isReversed);
// TODO: 实现反向剖切的逻辑
},
onFitToModel: () => {
console.log('[SectionBoxDialogManager] 适应到模型');
// TODO: 实现自动适应模型的逻辑
},
onReset: () => {
console.log('[SectionBoxDialogManager] 重置');
// 注意:不要在这里调用 panel.reset(),会造成无限递归
// panel 的 reset 按钮已经在内部处理了状态重置
// TODO: 这里只需要通知 3D 引擎重置剖切盒即可
},
onRangeChange: (range) => {
console.log('[SectionBoxDialogManager] 范围变化:', range);
// TODO: 实现范围变化的逻辑
}
});
this.panel.init();
// 创建弹窗
const dialogWidth = 280;
const paddingRight = 20;
const paddingBottom = 50;
const container = this.engine.container;
const containerWidth = container.clientWidth;
const containerHeight = container.clientHeight;
const x = containerWidth - dialogWidth - paddingRight;
const y = containerHeight - paddingBottom - 300; // 临时y值会被fitHeight调整
this.dialog = this.engine.dialog.create({
id: this.dialogId,
title: 'sectionBox.dialogTitle',
width: dialogWidth,
height: 'auto',
position: { x, y },
draggable: true,
resizable: false,
content: this.panel.element,
onClose: () => {
this.engine.toolbar?.setBtnActive('section-box', false);
this.hide();
}
});
this.dialog.init();
// 自适应高度
this.dialog.fitHeight(false);
}
/**
* 隐藏弹窗
*/
public hide(): void {
this.destroy();
}
/**
* 获取隐藏状态
*/
public getHiddenState(): boolean {
return this.panel?.getHiddenState() ?? false;
}
/**
* 设置隐藏状态
*/
public setHiddenState(isHidden: boolean): void {
this.panel?.setHiddenState(isHidden);
}
/**
* 获取反向状态
*/
public getReversedState(): boolean {
return this.panel?.getReversedState() ?? false;
}
/**
* 设置反向状态
*/
public setReversedState(isReversed: boolean): void {
this.panel?.setReversedState(isReversed);
}
/**
* 获取范围值
*/
public getRange(): SectionBoxRange | null {
return this.panel?.getRange() ?? null;
}
/**
* 设置范围值
*/
public setRange(range: Partial<SectionBoxRange>): void {
this.panel?.setRange(range);
}
/**
* 销毁弹窗和面板
*/
public destroy(): void {
// 关闭弹窗
if (this.dialog) {
this.dialog.destroy();
this.dialog = null;
}
// 销毁面板
if (this.panel) {
this.panel.destroy();
this.panel = null;
}
}
}

View File

@@ -0,0 +1,98 @@
import { BimComponent } from '../core/component';
import { BimEngine } from '../bim-engine';
import { BimDialog } from '../components/dialog';
import { SectionPlanePanel } from '../components/section-plane-panel';
/**
* 拾取面剖切弹窗管理器
*/
export class SectionPlaneDialogManager extends BimComponent {
private dialogId = 'section-plane-dialog';
private dialog: BimDialog | null = null;
private panel: SectionPlanePanel | 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 SectionPlanePanel({
onHide: () => {
console.log('[SectionPlaneDialogManager] 隐藏');
// TODO: 调用引擎的隐藏功能
},
onReverse: () => {
console.log('[SectionPlaneDialogManager] 反向');
// TODO: 调用引擎的反向功能
},
onReset: () => {
console.log('[SectionPlaneDialogManager] 重置');
// TODO: 调用引擎的重置功能
}
});
this.panel.init();
// 创建弹窗
const dialogWidth = 240;
const dialogHeight = 120;
const paddingRight = 20;
const paddingBottom = 50;
const container = this.engine.container;
const containerWidth = container.clientWidth;
const containerHeight = container.clientHeight;
const x = containerWidth - dialogWidth - paddingRight;
const y = containerHeight - dialogHeight - paddingBottom;
this.dialog = this.engine.dialog.create({
id: this.dialogId,
title: 'sectionPlane.dialogTitle',
width: dialogWidth,
height: dialogHeight,
position: { x, y },
draggable: true,
resizable: false,
content: this.panel.element,
onClose: () => {
this.engine.toolbar?.setBtnActive('section-plane', false);
this.hide();
}
});
}
/**
* 隐藏弹窗
*/
public hide(): void {
this.destroy();
}
/**
* 销毁弹窗
*/
public destroy(): void {
if (this.dialog) {
this.dialog.destroy();
this.dialog = null;
}
if (this.panel) {
this.panel.destroy();
this.panel = null;
}
}
}