1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- import { dataService } from "../Service/DataService";
- import { lineService } from "../Service/LineService";
- import { listenLayer } from "../ListenLayer";
- import VectorCategory from "../enum/VectorCategory";
- export default class AddLine {
- constructor() {
- this.startInfo = {};
- this.endInfo = {};
- this.category = VectorCategory.Line.NormalLine;
- }
- setPointInfo(dir, pointInfo) {
- if (dir == "start") {
- this.startInfo = {
- position: {
- x: pointInfo.x,
- y: pointInfo.y,
- },
- linkedPointId: pointInfo.linkedPointId,
- lineId: pointInfo.lineId,
- };
- } else if (dir == "end") {
- this.endInfo = {
- position: {
- x: pointInfo.x,
- y: pointInfo.y,
- },
- linkedPointId: pointInfo.linkedPointId,
- lineId: pointInfo.lineId,
- };
- }
- }
- setNewLinePoint(dir, position) {
- if (dir == "start") {
- if (listenLayer.modifyPoint) {
- this.setPointInfo(dir, listenLayer.modifyPoint);
- } else {
- this.setPointInfo(dir, position);
- }
- return true;
- } else if (dir == "end") {
- if (listenLayer.modifyPoint) {
- this.setPointInfo(dir, listenLayer.modifyPoint);
- } else {
- this.setPointInfo(dir, position);
- }
- return true;
- }
- return false;
- }
- buildLine() {
- lineService.create(
- this.startInfo.position,
- this.endInfo.position,
- this.category
- );
- listenLayer.clear();
- this.clear();
- }
- clear() {
- this.startInfo = {};
- this.endInfo = {};
- }
- }
- const addLine = new AddLine();
- export { addLine };
|