Browse Source

取消显示放大镜层,优化测量交互,支持 HipOneRay 测量方式

gavin.chen 2 years ago
parent
commit
bda17dfc00

+ 1 - 1
lib/process/items/top_item.dart

@@ -111,7 +111,7 @@ abstract class TopMeasureItem<T extends MeasureItemFeature>
       doCalculate();
     }
     if (ifAutoFinish) {
-      if (args.pointType == PointInfoType.touchDown) {
+      if (args.pointType == PointInfoType.touchUp) {
         if (childrenAllDone) {
           application.autoStartAgain(meta);
         }

+ 42 - 2
lib/process/primitives/ray.dart

@@ -58,10 +58,50 @@ class Ray extends MeasureItem<RayFeature> {
     return true;
   }
 
+  // 是否需要结束当前的测量过程,用于移动端的交互
+  bool isNeedFinish = true;
+  bool isFirstTouch = true;
+  DPoint touchStartPoint = DPoint(0, 0);
+  DPoint lastLinePosition = DPoint(0, 0);
   @override
   bool onExecuteTouch(PointInfo args) {
-    // TODO: implement onExecuteTouch
-    throw UnimplementedError();
+    if (state == ItemStates.waiting || state == ItemStates.finished) {
+      if (args.pointType == PointInfoType.touchMove) {
+        if (measuredFeatures.isEmpty) {
+          feature = RayFeature(this, args);
+          feature!.hostVisualArea = args.hostVisualArea;
+          final viewport = args.hostVisualArea!.viewport!;
+          feature!.isReverse =
+              viewport.isFlipHorizontal ^ viewport.isFlipVertical;
+        } else {
+          feature = measuredFeatures.first;
+        }
+        state = ItemStates.running;
+      }
+    }
+
+    if (state == ItemStates.running) {
+      if (args.pointType == PointInfoType.touchDown) {
+        touchStartPoint = args;
+        lastLinePosition = feature?.point ?? args;
+        isNeedFinish = true;
+        isFirstTouch = feature?.point == null;
+      }
+      if (args.pointType == PointInfoType.touchMove) {
+        isNeedFinish = false;
+        if (isFirstTouch) {
+          feature?.point = args;
+        } else {
+          feature?.point =
+              lastLinePosition.clone().addVector(args - touchStartPoint);
+        }
+        doCalculate();
+      }
+      if (args.pointType == PointInfoType.touchUp && isNeedFinish) {
+        doFeatureFinish();
+      }
+    }
+    return true;
   }
 
   static Ray createRay(ItemMeta meta, [IMeasureItem? parent]) {

+ 38 - 18
lib/process/primitives/straightline.dart

@@ -4,14 +4,10 @@ import 'package:fis_measure/interfaces/date_types/point.dart';
 import 'package:fis_measure/interfaces/enums/items.dart';
 import 'package:fis_measure/interfaces/process/items/item.dart';
 import 'package:fis_measure/interfaces/process/items/item_metas.dart';
-import 'package:fis_measure/interfaces/process/items/terms.dart';
 import 'package:fis_measure/interfaces/process/items/types.dart';
 import 'package:fis_measure/interfaces/process/workspace/point_info.dart';
-import 'package:fis_measure/process/calcuators/heart_rate.dart';
 import 'package:fis_measure/process/calcuators/time_motion.dart';
 import 'package:fis_measure/process/items/item.dart';
-import 'package:fis_measure/process/primitives/combos/depth2baseline.dart';
-import 'package:fis_measure/process/primitives/location.dart';
 import 'package:fis_measure/utils/canvas.dart';
 import 'package:fis_measure/view/gesture/cross_position_indicator.dart';
 import 'package:fis_measure/view/gesture/positioned_cursor.dart';
@@ -91,11 +87,16 @@ class StraightLine extends MeasureItem<StraightLineFeature> {
     return true;
   }
 
-  PointInfo? startPoint;
+  PointInfo? firstTouchStartPoint;
+  bool isFirstPointMove = false;
+  DPoint? secondTouchStartPoint;
+  bool isSecondPointMove = false;
   @override
   bool onExecuteTouch(PointInfo args) {
     if (state == ItemStates.finished) {
       if (args.pointType == PointInfoType.touchDown) {
+        isFirstPointMove = false;
+        isSecondPointMove = false;
         state = ItemStates.waiting;
       }
     }
@@ -103,28 +104,47 @@ class StraightLine extends MeasureItem<StraightLineFeature> {
     if (state == ItemStates.waiting) {
       switch (args.pointType) {
         case PointInfoType.touchDown:
-          startPoint = args; // 设置线段起点
-          handleTouchBeforeStart(startPoint!); // 开始绘制前动态设置第一个起点
-          break;
-        case PointInfoType.touchUp:
-          startPoint = args; // 设置线段起点
-          feature?.startPoint = args;
-          state = ItemStates.running;
+          firstTouchStartPoint = args; // 设置线段起点
+          handleTouchBeforeStart(firstTouchStartPoint!); // 开始绘制前动态设置第一个起点
           break;
         case PointInfoType.touchMove:
+          isFirstPointMove = true;
+          args.addOffset(0, -0.2); // 添加偏移
           feature?.startPoint = args;
           feature?.endPoint = args;
           break;
+        case PointInfoType.touchUp:
+          if (isFirstPointMove) {
+            args.addOffset(0, -0.2); // 添加偏移
+          }
+          firstTouchStartPoint = args; // 设置线段起点
+          feature?.startPoint = args;
+          state = ItemStates.running;
+          break;
         default:
           break;
       }
     } else if (state == ItemStates.running) {
-      if (args.pointType == PointInfoType.touchUp) {
-        doFeatureFinish();
-      }
-      if (args.pointType == PointInfoType.touchMove) {
-        doCalculate();
-        feature?.endPoint = args;
+      switch (args.pointType) {
+        case PointInfoType.touchDown:
+          secondTouchStartPoint = args;
+          break;
+        case PointInfoType.touchMove:
+          isSecondPointMove = true;
+          doCalculate();
+          feature?.endPoint = firstTouchStartPoint!
+              .clone()
+              .addVector(args - secondTouchStartPoint!);
+          break;
+        case PointInfoType.touchUp:
+          if (!isSecondPointMove) {
+            feature?.endPoint = args;
+            doCalculate();
+          }
+          doFeatureFinish();
+          break;
+        default:
+          break;
       }
     }
     return true;

+ 6 - 6
lib/view/mobile_view/mobile_measure_main_view.dart

@@ -415,10 +415,10 @@ class _MobileMeasureMainViewState extends State<MobileMeasureMainView> {
                       id: _LayerLayoutIds.currActiveAreaIndicator,
                       child: const MeasureAreaIndicator(),
                     ),
-                    LayoutId(
-                      id: _LayerLayoutIds.canvasMagnifier,
-                      child: const CanvasMagnifier(),
-                    ),
+                    // LayoutId(
+                    //   id: _LayerLayoutIds.canvasMagnifier,
+                    //   child: const CanvasMagnifier(),
+                    // ),
                   ],
                   if (isPlayerMode && canShowAI) ...[
                     LayoutId(
@@ -484,7 +484,7 @@ class _LayerLayoutDelegate extends MultiChildLayoutDelegate {
     layoutLayer(_LayerLayoutIds.activeAnnotation, offset, renderSize);
     layoutLayer(_LayerLayoutIds.standardLineCalibration, offset, renderSize);
     layoutLayer(_LayerLayoutIds.currActiveAreaIndicator, offset, renderSize);
-    layoutLayer(_LayerLayoutIds.canvasMagnifier, offset, renderSize);
+    // layoutLayer(_LayerLayoutIds.canvasMagnifier, offset, renderSize);
     layoutLayer(_LayerLayoutIds.gesture, offset, renderSize);
     layoutLayer(
       _LayerLayoutIds.result,
@@ -542,7 +542,7 @@ enum _LayerLayoutIds {
   player,
 
   /// 画布放大镜层
-  canvasMagnifier,
+  // canvasMagnifier,
 
   /// 测量记录画板
   recordsCanvas,

+ 1 - 0
lib/view/mobile_view/mobile_right_panel/mobile_measure_tool.dart

@@ -589,6 +589,7 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
       "Depth", // Location
       "Velocity", // Location
       "MDepth", // Location
+      "HipOneRay", // Ray && Ray
     ];
     List<ItemMetaDTO> _supportedItems = [];
     if (mode.availableGroups == null || mode.availableGroups!.isEmpty) {