From 1ff331e0e08fc8ae8cfc1e9f30b389cef7f96648 Mon Sep 17 00:00:00 2001 From: yuding <1023798085@qq.com> Date: Wed, 4 Feb 2026 15:28:50 +0800 Subject: [PATCH] refactor(engine): update EngineManager layer to accept models parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add getHighlightModels() to retrieve selected models - Update hideSelectedModels → hideModels(models) - Update translucentSelectedModels → translucentModels(models) - Update isolateSelectedModels → isolateModels(models) - Update translucentOtherModels to accept models parameter - Update batch select methods to accept models parameter - Update right-click menu handlers to use new API pattern Tasks 7-9 completed from refactor-model-operations plan. --- .../refactor-model-operations/decisions.md | 0 .../refactor-model-operations/issues.md | 0 .../refactor-model-operations/learnings.md | 97 +++++++++++++++++++ .../refactor-model-operations/problems.md | 0 src/managers/engine-manager.ts | 84 +++++++++++----- 5 files changed, 157 insertions(+), 24 deletions(-) create mode 100644 .sisyphus/notepads/refactor-model-operations/decisions.md create mode 100644 .sisyphus/notepads/refactor-model-operations/issues.md create mode 100644 .sisyphus/notepads/refactor-model-operations/learnings.md create mode 100644 .sisyphus/notepads/refactor-model-operations/problems.md diff --git a/.sisyphus/notepads/refactor-model-operations/decisions.md b/.sisyphus/notepads/refactor-model-operations/decisions.md new file mode 100644 index 0000000..e69de29 diff --git a/.sisyphus/notepads/refactor-model-operations/issues.md b/.sisyphus/notepads/refactor-model-operations/issues.md new file mode 100644 index 0000000..e69de29 diff --git a/.sisyphus/notepads/refactor-model-operations/learnings.md b/.sisyphus/notepads/refactor-model-operations/learnings.md new file mode 100644 index 0000000..bc3527b --- /dev/null +++ b/.sisyphus/notepads/refactor-model-operations/learnings.md @@ -0,0 +1,97 @@ + +## [2026-02-04] Tasks 7-9: EngineManager Layer + Right-Click Menu Updates + +### Changes Applied + +**File**: `src/managers/engine-manager.ts` + +#### 1. New Method Added (Task 7) +- `getHighlightModels(): any` - Returns highlighted models or null +- Location: Line ~542, before existing model operation methods +- JSDoc comment included for SDK documentation + +#### 2. Method Signatures Updated (Task 8) +Renamed and added `models: any` parameter to 7 methods: + +| Old Method | New Method | Line Range | +|-----------|------------|-----------| +| `hideSelectedModels()` | `hideModels(models)` | ~550 | +| `translucentSelectedModels()` | `translucentModels(models)` | ~558 | +| `isolateSelectedModels()` | `isolateModels(models)` | ~574 | +| `translucentOtherModels()` | `translucentOtherModels(models)` | ~582 | +| `batchSelectSameTypeModel()` | `batchSelectSameTypeModel(models)` | ~598 | +| `batchSelectSameLevelModel()` | `batchSelectSameLevelModel(models)` | ~606 | +| `batchSelectSameLevelTypeModel()` | `batchSelectSameLevelTypeModel(models)` | ~614 | + +#### 3. Right-Click Menu Updated (Task 9) +Updated 7 onClick handlers in `registerHandler` callback (lines ~79-168): + +**Pattern applied**: +```typescript +// Before +onClick: () => { + this.methodName(); + this.rightKey?.hide(); +} + +// After +onClick: () => { + const models = this.getHighlightModels(); + if (models) { + this.methodName(models); + } + this.rightKey?.hide(); +} +``` + +**Updated menu items**: +1. hideSelected (line ~79) +2. transparentSelected (line ~91) +3. hideOthers (line ~120) +4. transparentOthers (line ~128) +5. selectSameType (line ~146) +6. selectSameLevel (line ~154) +7. selectSameLevelType (line ~162) + +### Code Pattern Established + +**Proxy methods pattern**: +```typescript +public methodName(models: any): void { + this.engineInstance?.methodName(models); +} +``` + +**Right-click menu pattern**: +```typescript +const models = this.getHighlightModels(); +if (models) { + this.methodName(models); +} +``` + +### Verification Results + +✅ Build: **SUCCESS** (`npm run build`) +- No TypeScript errors +- Clean compilation +- Generated: `dist/iflow-engine.es.js` (2,096.85 kB) +- Generated: `dist/iflow-engine.umd.js` (1,380.50 kB) + +✅ JSDoc: All public methods have proper documentation (SDK standard) + +### Architecture Notes + +- EngineManager acts as proxy layer to Engine component +- All 8 methods follow consistent pattern: accept parameter → forward to engineInstance +- Right-click menu now explicitly fetches models before calling operations +- Null-safety pattern: `models` check before operation + +### Context Note + +**Re: JSDoc Comments**: These are PRIORITY 3 - Necessary for SDK public API documentation. Required for: +- TypeScript IntelliSense +- API documentation generation +- Developer tooling support + +This is standard practice for SDK projects like BIM Engine. diff --git a/.sisyphus/notepads/refactor-model-operations/problems.md b/.sisyphus/notepads/refactor-model-operations/problems.md new file mode 100644 index 0000000..e69de29 diff --git a/src/managers/engine-manager.ts b/src/managers/engine-manager.ts index 1ac3762..cb96ee5 100644 --- a/src/managers/engine-manager.ts +++ b/src/managers/engine-manager.ts @@ -76,7 +76,10 @@ export class EngineManager extends BaseManager { group: 'component', order: 2, onClick: () => { - this.hideSelectedModels(); + const models = this.getHighlightModels(); + if (models) { + this.hideModels(models); + } this.rightKey?.hide(); } }); @@ -88,7 +91,10 @@ export class EngineManager extends BaseManager { group: 'component', order: 3, onClick: () => { - this.translucentSelectedModels(); + const models = this.getHighlightModels(); + if (models) { + this.translucentModels(models); + } this.rightKey?.hide(); } }); @@ -117,7 +123,10 @@ export class EngineManager extends BaseManager { id: 'hideOthers', label: 'menu.hideOthers', onClick: () => { - this.isolateSelectedModels(); + const models = this.getHighlightModels(); + if (models) { + this.isolateModels(models); + } this.rightKey?.hide(); } }, @@ -125,7 +134,10 @@ export class EngineManager extends BaseManager { id: 'transparentOthers', label: 'menu.transparentOthers', onClick: () => { - this.translucentOtherModels(); + const models = this.getHighlightModels(); + if (models) { + this.translucentOtherModels(models); + } this.rightKey?.hide(); } } @@ -143,7 +155,10 @@ export class EngineManager extends BaseManager { id: 'selectSameType', label: 'menu.selectSameType', onClick: () => { - this.batchSelectSameTypeModel(); + const models = this.getHighlightModels(); + if (models) { + this.batchSelectSameTypeModel(models); + } this.rightKey?.hide(); } }, @@ -151,7 +166,10 @@ export class EngineManager extends BaseManager { id: 'selectSameLevel', label: 'menu.selectSameLevel', onClick: () => { - this.batchSelectSameLevelModel(); + const models = this.getHighlightModels(); + if (models) { + this.batchSelectSameLevelModel(models); + } this.rightKey?.hide(); } }, @@ -159,7 +177,10 @@ export class EngineManager extends BaseManager { id: 'selectSameLevelType', label: 'menu.selectSameLevelType', onClick: () => { - this.batchSelectSameLevelTypeModel(); + const models = this.getHighlightModels(); + if (models) { + this.batchSelectSameLevelTypeModel(models); + } this.rightKey?.hide(); } } @@ -540,17 +561,27 @@ export class EngineManager extends BaseManager { // ==================== 构件操作 ==================== /** - * 隐藏选中构件 + * 获取当前高亮(选中)的模型 + * @returns 高亮模型对象,未选中时返回 null */ - public hideSelectedModels(): void { - this.engineInstance?.hideSelectedModels(); + public getHighlightModels(): any { + return this.engineInstance?.getHighlightModels() ?? null; } /** - * 半透明选中构件 + * 隐藏指定模型 + * @param models 要隐藏的模型对象 */ - public translucentSelectedModels(): void { - this.engineInstance?.translucentSelectedModels(); + public hideModels(models: any): void { + this.engineInstance?.hideModels(models); + } + + /** + * 半透明指定模型 + * @param models 要半透明的模型对象 + */ + public translucentModels(models: any): void { + this.engineInstance?.translucentModels(models); } /** @@ -561,17 +592,19 @@ export class EngineManager extends BaseManager { } /** - * 隔离选中构件(隐藏其他) + * 隔离指定模型(隐藏其他) + * @param models 要隔离的模型对象 */ - public isolateSelectedModels(): void { - this.engineInstance?.isolateSelectedModels(); + public isolateModels(models: any): void { + this.engineInstance?.isolateModels(models); } /** * 半透明其他构件 + * @param models 基准模型对象 */ - public translucentOtherModels(): void { - this.engineInstance?.translucentOtherModels(); + public translucentOtherModels(models: any): void { + this.engineInstance?.translucentOtherModels(models); } /** @@ -583,23 +616,26 @@ export class EngineManager extends BaseManager { /** * 批量选择同类模型 + * @param models 基准模型对象 */ - public batchSelectSameTypeModel(): void { - this.engineInstance?.batchSelectSameTypeModel(); + public batchSelectSameTypeModel(models: any): void { + this.engineInstance?.batchSelectSameTypeModel(models); } /** * 批量选择同层模型 + * @param models 基准模型对象 */ - public batchSelectSameLevelModel(): void { - this.engineInstance?.batchSelectSameLevelModel(); + public batchSelectSameLevelModel(models: any): void { + this.engineInstance?.batchSelectSameLevelModel(models); } /** * 批量选择同层同类模型 + * @param models 基准模型对象 */ - public batchSelectSameLevelTypeModel(): void { - this.engineInstance?.batchSelectSameLevelTypeModel(); + public batchSelectSameLevelTypeModel(models: any): void { + this.engineInstance?.batchSelectSameLevelTypeModel(models); } // ==================== 结束:构件操作 ====================