xushiting 2 years ago
parent
commit
33af5d9e1d
3 changed files with 18 additions and 9 deletions
  1. 6 0
      src/graphic/Controls/AddPoint.js
  2. 3 1
      src/graphic/Coordinate.js
  3. 9 8
      src/graphic/Layer.js

+ 6 - 0
src/graphic/Controls/AddPoint.js

@@ -40,6 +40,12 @@ export default class AddPoint {
         newPoint = pointService.create(position);
         this.setLocationByNormal(newPoint.vectorId);
         newPoint.setLocationMode(Constant.normalLocationMode);
+      } else if (
+        Settings.selectBasePointId == null &&
+        (Settings.locationMode == Constant.angleLocationMode ||
+          Settings.locationMode == Constant.allLocationMode)
+      ) {
+        return null;
       }
       if (
         newPoint &&

+ 3 - 1
src/graphic/Coordinate.js

@@ -7,7 +7,7 @@ export default class Coordinate {
     this.defaultZoom = defaultZoom;
     this.zoom = defaultZoom; // 当前缩放比例,不会改变世界坐标系的坐标,只是改变渲染时转换的屏幕坐标
     this.res = defaultRes; //比例尺。实际尺寸与屏幕像素的比例,用于测量。与之前的绘制不同,目前存储的数据与像素的比例是1:1,只是最后测量值再除以这个比例
-    this.ratio = 1; //不同硬件设备,像素率不同
+    this.ratio = window.devicePixelRatio || 1; //不同硬件设备,像素率不同
 
     this.width == null;
     this.height == null;
@@ -77,6 +77,8 @@ export default class Coordinate {
 
   updateForCanvas(canvas) {
     if (canvas) {
+      canvas.width *= this.ratio;
+      canvas.height *= this.ratio;
       this.width = canvas.clientWidth;
       this.height = canvas.clientHeight;
     }

+ 9 - 8
src/graphic/Layer.js

@@ -204,17 +204,17 @@ export default class Layer {
         //记录开始的两个触摸点的坐标
         if (!this.StorePage1 || !this.StorePage2) {
           this.onMouseUp(e);
-          this.StorePage1 = { x: ev.touches[0].pageX, y: ev.touches[0].pageY };
-          this.StorePage2 = { x: ev.touches[1].pageX, y: ev.touches[1].pageY };
+          this.StorePage1 = { x: e.touches[0].pageX, y: e.touches[0].pageY };
+          this.StorePage2 = { x: e.touches[1].pageX, y: e.touches[1].pageY };
           return;
         }
         const point1 = {
-          x: ev.touches[0].pageX,
-          y: ev.touches[0].pageY,
+          x: e.touches[0].pageX,
+          y: e.touches[0].pageY,
         };
         const point2 = {
-          x: ev.touches[1].pageX,
-          y: ev.touches[1].pageY,
+          x: e.touches[1].pageX,
+          y: e.touches[1].pageY,
         };
 
         // let zoom =
@@ -223,8 +223,9 @@ export default class Layer {
         //   coordinate.defaultZoom;
         let zoom =
           coordinate.defaultZoom +
-          mathUtil.getDistance(this.StorePage1, this.StorePage2) -
-          mathUtil.getDistance(point1, point2);
+          mathUtil.getDistance(point1, point2) -
+          mathUtil.getDistance(this.StorePage1, this.StorePage2);
+
         this.zoomVector(zoom);
         return;
       }