Browse Source

y轴反转

任一存 1 year ago
parent
commit
6e16b67614
2 changed files with 15 additions and 11 deletions
  1. 5 1
      README.md
  2. 10 10
      src/App.vue

+ 5 - 1
README.md

@@ -67,4 +67,8 @@ history最大条数
 
 单击点位高亮周围的点,并展示id,并填充补点的高度。 check
 
-y轴反转
+y轴反转 check
+
+补点后已有点位的数据未及时更新
+
+上次激活的点无法hover高亮

+ 10 - 10
src/App.vue

@@ -495,7 +495,7 @@ export default {
         return eachPoint.y
       })
       let yLength = Math.max(...yArray) - Math.min(...yArray)
-      yCenter = (Math.max(...yArray) + Math.min(...yArray)) / 2
+      yCenter = (Math.max(...yArray) + Math.min(...yArray)) / 2 
       let zArray = rawWholeData.map((eachPoint) => {
         return eachPoint.z
       })
@@ -513,7 +513,7 @@ export default {
         return (eachX - xCenter) * pxPerUnitLength + svgWidth / 2
       })
       let wholeYArrayInPx = yArray.map((eachY) => {
-        return (eachY - yCenter) * pxPerUnitLength + svgHeight / 2
+        return (-1) * (eachY - yCenter) * pxPerUnitLength + svgHeight / 2
       })
 
       // 组合成最终数据用来渲染
@@ -882,16 +882,16 @@ export default {
       
       // 选择框位置复原到原始坐标系
       const brushLeft = (brushLeftPxBeformTransform - svgWidth / 2) / pxPerUnitLength + xCenter
-      const brushTop = (brushTopPxBeformTransform - svgHeight / 2) / pxPerUnitLength + yCenter
+      const brushTop = (brushTopPxBeformTransform - svgHeight / 2) / pxPerUnitLength * (-1) + yCenter
       const brushRight = (brushRightPxBeformTransform - svgWidth / 2) / pxPerUnitLength + xCenter
-      const brushBottom = (brushBottomPxBeformTransform - svgHeight / 2) / pxPerUnitLength + yCenter
+      const brushBottom = (brushBottomPxBeformTransform - svgHeight / 2) / pxPerUnitLength * (-1) + yCenter
       console.log('brush area in raw coordinate: ', brushLeft, brushTop, brushRight, brushBottom);
 
       // 计算出选择框的外围影响区域
       const affectionAreaLeft = brushLeft - pointDistance * Math.SQRT2 * 1.25
-      const affectionAreaTop = brushTop - pointDistance * Math.SQRT2 * 1.25
+      const affectionAreaTop = brushTop + pointDistance * Math.SQRT2 * 1.25
       const affectionAreaRight = brushRight + pointDistance * Math.SQRT2 * 1.25
-      const affectionAreaBottom = brushBottom + pointDistance * Math.SQRT2 * 1.25
+      const affectionAreaBottom = brushBottom - pointDistance * Math.SQRT2 * 1.25
       console.log('affection area in raw coordinate: ', affectionAreaLeft, affectionAreaTop, affectionAreaRight, affectionAreaBottom);
 
       // 筛选出框选区域可能影响到的所有外围点
@@ -904,11 +904,11 @@ export default {
           continue
         }
         // 如果在affection范围外,pass
-        if (point.x < affectionAreaLeft || point.x > affectionAreaRight || point.y < affectionAreaTop || point.y > affectionAreaBottom) {
+        if (point.x < affectionAreaLeft || point.x > affectionAreaRight || point.y < affectionAreaBottom || point.y > affectionAreaTop) {
           continue
         }
         // 如果在框选区域内,pass
-        if (point.x >= brushLeft && point.x <= brushRight && point.y >= brushTop && point.y <= brushBottom) {
+        if (point.x >= brushLeft && point.x <= brushRight && point.y <= brushTop && point.y >= brushBottom) {
           continue
         }
         affectedPointList.push(point)
@@ -926,7 +926,7 @@ export default {
           continue
         }
         // 如果在框选区域内,留下
-        if (point.x >= brushLeft && point.x <= brushRight && point.y >= brushTop && point.y <= brushBottom) {
+        if (point.x >= brushLeft && point.x <= brushRight && point.y <= brushTop && point.y >= brushBottom) {
           pointInBrushList.push(point)
         }
       }
@@ -977,7 +977,7 @@ export default {
             const neiPos = neighbourPosList[key];
 
             // 如果点位在框选区域外
-            if (neiPos.x < brushLeft || neiPos.x > brushRight || neiPos.y < brushTop || neiPos.y > brushBottom) {
+            if (neiPos.x < brushLeft || neiPos.x > brushRight || neiPos.y > brushTop || neiPos.y < brushBottom) {
               // 在外围点位表中找匹配的点
               const matchedPoint = affectedPointList.find((affectedPoint) => {
                 return getDistance2D(affectedPoint, neiPos) < pointDistance * 0.1