1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import {AttachCAD as CAD} from '../index'
- import { CADElement } from '../core/element'
- import LineArch from '../architecture/linearch'
- import Column from '../architecture/column'
- export interface Disabled {
- forbidden: Function
- available: Function
- }
- // 启用或禁用cad
- export const attachDisabled = (cad: CAD) => {
- let editApis = ['increase', 'getStackState', 'preservation', 'previous', 'next', 'closeMouseHandle', 'showGauge', 'hideGauge']
- let apiFuns = []
- // 禁用cad所有交互取消
- cad.forbidden = () => {
- if (apiFuns.length === editApis.length) return;
-
- cad.hideGauge()
- cad.closeMouseHandle()
- CADElement.examples.get(cad.processing.render).forEach(e => e.unEvent())
- LineArch.attaArch.forEach(archs => {
- archs.forEach(arch => {
- arch instanceof Column && arch.delEvent()
- })
- })
- editApis.forEach(key => {
- apiFuns.push(cad[key])
- delete cad[key]
- })
- }
- // 启用cad激活操作
- cad.available = () => {
- if (apiFuns.length !== editApis.length) return;
- editApis.forEach((key, i) => cad[key] = apiFuns[i])
- apiFuns = []
- CADElement.examples.get(cad.processing.render).forEach(e => e.listen());
-
- LineArch.attaArch.forEach(archs => {
- archs.forEach(arch => arch instanceof Column && arch.addEvent())
- })
- cad.showGauge()
- cad.openMouseHandle()
- }
- }
|