Browse Source

继续补充

xushiting 2 years ago
parent
commit
e760bdaa0f

+ 1 - 1
src/graphic/Controls/AddCircle.js

@@ -1,5 +1,6 @@
 import { mathUtil } from "../Util/MathUtil";
 import { circleService } from "../Service/CircleService";
+import { listenLayer } from "../ListenLayer";
 
 export default class AddCircle {
   constructor() {
@@ -19,7 +20,6 @@ export default class AddCircle {
   buildCircle() {
     circleService.create(this.center, this.radius);
     listenLayer.clear();
-    this.clear();
   }
 
   clear() {

+ 4 - 1
src/graphic/Controls/AddLine.js

@@ -61,7 +61,10 @@ export default class AddLine {
       this.category
     );
     listenLayer.clear();
-    this.clear();
+  }
+
+  setCategory(value) {
+    this.category = value;
   }
 
   setBaseLineId(baseLineId) {

+ 1 - 2
src/graphic/Controls/AddSVG.js

@@ -1,5 +1,6 @@
 import { mathUtil } from "../Util/MathUtil";
 import { svgService } from "../Service/SVGService";
+import { listenLayer } from "../ListenLayer";
 
 export default class AddSVG {
   constructor() {
@@ -14,8 +15,6 @@ export default class AddSVG {
 
   buildSVG(center) {
     this.newSVG = svgService.create(center);
-    listenLayer.clear();
-    this.clear();
   }
 
   clear() {

+ 1 - 1
src/graphic/Controls/AddText.js

@@ -1,5 +1,6 @@
 import { mathUtil } from "../Util/MathUtil";
 import { textService } from "../Service/TextService";
+import { listenLayer } from "../ListenLayer";
 
 export default class AddText {
   constructor() {
@@ -20,7 +21,6 @@ export default class AddText {
   buildText(center) {
     this.newText = textService.create(center);
     listenLayer.clear();
-    this.clear();
   }
 
   clear() {

+ 1 - 0
src/graphic/Controls/MoveText.js

@@ -1,4 +1,5 @@
 import { dataService } from "../Service/DataService";
+import { mathUtil } from "../Util/MathUtil";
 
 export default class MoveText {
   constructor() {}

+ 5 - 0
src/graphic/Controls/UIControl.js

@@ -12,6 +12,8 @@ import { textService } from "../Service/TextService.js/";
 import Constant from "../Constant";
 // import { roomsUtil } from "../Room/RoomsUtil.js";
 import { addRoad } from "../Controls/AddRoad";
+import { addLine } from "./AddLine.js";
+import VectorCategory from "../enum/VectorCategory.js";
 // import { floorplanData } from "../VectorData.js";
 
 export default class UIControl {
@@ -70,6 +72,9 @@ export default class UIControl {
           stateService.setEventName(LayerEvents.AddRoad);
         } else if (selectUI == UIEvents.CurveRoad) {
           stateService.setEventName(LayerEvents.AddCurveRoad);
+        } else if (selectUI == UIEvents.Arrow) {
+          stateService.setEventName(LayerEvents.AddLine);
+          addLine.setCategory(VectorCategory.Line.MeasureLine);
         } else if (selectUI == UIEvents.Line) {
           stateService.setEventName(LayerEvents.AddLine);
         } else if (selectUI == UIEvents.Circle) {

+ 6 - 1
src/graphic/Layer.js

@@ -107,7 +107,6 @@ export default class Layer {
     //用于支持平板电脑
     listenLayer.start(position);
     this.setEventName("mouseDown");
-    const selectItem = stateService.getSelectItem();
     const eventName = stateService.getEventName();
     switch (eventName) {
       case LayerEvents.AddRoad:
@@ -134,6 +133,7 @@ export default class Layer {
           VectorType.Text,
           SelectState.Select
         );
+        addText.clear();
         break;
       case LayerEvents.AddMagnifier:
         stateService.setEventName(LayerEvents.MoveMagnifier);
@@ -143,6 +143,7 @@ export default class Layer {
           VectorType.Magnifier,
           SelectState.Select
         );
+        addMagnifier.clear();
         break;
       case LayerEvents.AddSVG:
         stateService.setEventName(LayerEvents.MoveSVG);
@@ -152,8 +153,10 @@ export default class Layer {
           VectorType.SVG,
           SelectState.Select
         );
+        addSVG.clear();
         break;
     }
+    const selectItem = stateService.getSelectItem();
     stateService.setDraggingItem(selectItem);
     // 清除上一个状态
     // 设置当前事件名称
@@ -646,12 +649,14 @@ export default class Layer {
       case LayerEvents.AddingLine:
         needAutoRedraw = true;
         addLine.buildLine();
+        addLine.clear();
         this.history.save();
         elementService.hideAll();
         break;
       case LayerEvents.AddingCircle:
         needAutoRedraw = true;
         addCircle.buildCircle();
+        addCircle.clear();
         this.history.save();
         elementService.hideAll();
         break;

+ 3 - 3
src/graphic/ListenLayer.js

@@ -79,7 +79,7 @@ export default class ListenLayer {
     );
     selectInfo.magnifierInfo = this.isSelectMagnifier(
       position,
-      exceptMagnifierId.exceptMagnifierId
+      exceptVectorIds.exceptMagnifierId
     );
     this.setModifyPoint(position, selectInfo);
     flag = this.updateSelectItem();
@@ -834,8 +834,8 @@ export default class ListenLayer {
     } else if (info && info.textInfo.textId) {
       this.modifyPoint = {};
       this.modifyPoint.textId = info.textInfo.textId;
-      this.modifyPoint.x = info.textInfo.center.x;
-      this.modifyPoint.y = info.textInfo.center.y;
+      this.modifyPoint.x = info.textInfo.x;
+      this.modifyPoint.y = info.textInfo.y;
     } else if (info && info.magnifierInfo.magnifierId) {
       this.modifyPoint = {};
       this.modifyPoint.magnifierId = info.magnifierInfo.magnifierId;