123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- import Constant from "../Constant";
- import { dataService } from "./DataService";
- import { stateService } from "./StateService";
- import { elementService } from "./ElementService";
- import { coordinate } from "../Coordinate";
- import VectorType from "../enum/VectorType";
- import SelectState from "../enum/SelectState.js";
- import LayerEvents from "../enum/LayerEvents.js";
- import { componentService } from "./ComponentService";
- import { symbolService } from "./SymbolService";
- import { furnitureService } from "./FurnitureService";
- import { tagService } from "./TagService";
- import { addRoad } from "../Controls/AddRoad";
- import UIEvents from "../enum/UIEvents.js";
- import { wallService } from "./WallService";
- import { moveRectangle } from "../Controls/MoveRectangle";
- export default class KeyService {
- constructor() {
- this.wallLineStyle = null;
- this.targetItem = null;
- }
- clearTargetItem() {
- this.targetItem = null;
- }
- copy(focusItem, mousePosition) {
- if (focusItem && focusItem.type) {
- this.targetItem = {
- vectorId: focusItem.vectorId,
- type: focusItem.type,
- };
- }
- this.paste(mousePosition);
- this.clearTargetItem();
- }
- //复制
- paste(mousePosition) {
- let flag = false;
- const position = coordinate.getXYFromScreen(mousePosition);
- // if (this.targetItem && componentService.isComponent(this.targetItem.type)) {
- // const component = dataService.getComponent(this.targetItem.vectorId)
- // const newComponent = componentService.createComponent(position, this.targetItem.type)
- // newComponent.angle = component.angle
- // newComponent.sideWidth = component.sideWidth
- // newComponent.sideThickness = component.sideThickness
- // stateService.setSelectItem(newComponent.vectorId, this.targetItem.type, SelectState.All)
- // stateService.setDraggingItem(stateService.selectItem)
- // stateService.setEventName(LayerEvents.MoveComponent)
- // flag = true
- // } else if (this.targetItem && this.targetItem.type == VectorType.Tag) {
- // let tag = dataService.getTag(this.targetItem.vectorId)
- // const newTag = tagService.createTag(position)
- // newTag.title = tag.title
- // newTag.des = tag.des
- // newTag.unit = tag.unit
- // newTag.adding = tag.adding
- // newTag.name = tag.name
- // stateService.setSelectItem(newTag.vectorId, this.targetItem.type, SelectState.All)
- // stateService.setDraggingItem(stateService.selectItem)
- // stateService.setEventName(LayerEvents.MoveTag)
- // flag = true
- // } else if (this.targetItem && furnitureService.isFurniture(this.targetItem.type)) {
- // const furniture = dataService.getFurniture(this.targetItem.vectorId)
- // const newFurniture = furnitureService.createFurniture(position, this.targetItem.type)
- // newFurniture.angle = furniture.angle
- // newFurniture.zoom = furniture.zoom
- // stateService.setSelectItem(newFurniture.vectorId, this.targetItem.type, SelectState.All)
- // stateService.setDraggingItem(stateService.selectItem)
- // stateService.setEventName(LayerEvents.MoveFurniture)
- // moveRectangle.clear()
- // flag = true
- // }
- if (this.targetItem && furnitureService.isFurniture(this.targetItem.type)) {
- const furniture = dataService.getFurniture(this.targetItem.vectorId);
- const newFurniture = furnitureService.createFurniture(
- position,
- this.targetItem.type
- );
- newFurniture.angle = furniture.angle;
- newFurniture.zoom = furniture.zoom;
- stateService.setSelectItem(
- newFurniture.vectorId,
- this.targetItem.type,
- SelectState.All
- );
- stateService.setDraggingItem(stateService.selectItem);
- stateService.setEventName(LayerEvents.MoveFurniture);
- moveRectangle.clear();
- flag = true;
- }
- stateService.clearFocusItem();
- return flag;
- }
- }
- const keyService = new KeyService();
- export { keyService };
|