123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- 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 };
|