import VectorType from "../enum/VectorType.js"; import SelectState from "../enum/SelectState.js"; export default class StateService { constructor() { this.eventName = null; this.selectItem = null; this.focusItem = null; this.draggingItem = null; } getEventName() { return this.eventName; } setEventName(eventName) { this.eventName = eventName; } clearEventName() { this.eventName = null; } // type表示类型,state默认是select,但是有的元素需要知道选中的是哪个顶点 setSelectItem(vectorId, type, state) { this.selectItem = {}; this.selectItem.vectorId = vectorId; this.selectItem.type = type; if (symbolService.isSymbol(type)) { if (state == SelectState.Select) { this.selectItem.selectIndex = SelectState.All; } else { this.selectItem.selectIndex = state; } } else if (componentService.isComponent(type)) { if (state == SelectState.Select) { this.selectItem.selectIndex = SelectState.All; } } else if (type == VectorType.Tag) { if (state == SelectState.Select) { this.selectItem.selectIndex = SelectState.All; } else { this.selectItem.selectIndex = state; } } else if (furnitureService.isFurniture(type)) { if (state == SelectState.Select) { this.selectItem.selectIndex = SelectState.All; } } } getSelectItem() { return this.selectItem; } clearSelectItem() { this.selectItem = null; } getDraggingItem() { return this.draggingItem; } setDraggingItem(draggingItem) { this.draggingItem = draggingItem; } clearDraggingItem() { this.draggingItem = null; } getFocusItem() { return this.focusItem; } setFocusItem(focusItem) { this.focusItem = focusItem; } clearFocusItem() { this.focusItem = null; } clearItems() { this.selectItem = null; this.focusItem = null; this.draggingItem = null; } } const stateService = new StateService(); export { stateService };