refactor(engine): update EngineManager layer to accept models parameter

- 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.
This commit is contained in:
yuding
2026-02-04 15:28:50 +08:00
parent a30e87e577
commit 1ff331e0e0
5 changed files with 157 additions and 24 deletions

View File

@@ -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.