Bladeren bron

update(measure): support Doppler Trace change side

gavin.chen 2 jaren geleden
bovenliggende
commit
a3577a103b
3 gewijzigde bestanden met toevoegingen van 196 en 80 verwijderingen
  1. 126 63
      assets/items.json
  2. 27 0
      lib/process/calcuators/trace.dart
  3. 43 17
      lib/process/primitives/multi_method/multiple_trace.dart

+ 126 - 63
assets/items.json

@@ -24,162 +24,194 @@
                 {
                     "Name": "TAMEAN",
                     "Description": "Mean Vel(Mean Mode)",
-                    "Unit": 70
+                    "Unit": 70,
+                    "IsWorking": true
                 },
                 {
                     "Name": "PS",
                     "Description": "PS",
-                    "Unit": 70
+                    "Unit": 70,
+                    "IsWorking": true
                 },
                 {
                     "Name": "ED",
                     "Description": "ED",
-                    "Unit": 70
+                    "Unit": 70,
+                    "IsWorking": true
                 },
                 {
                     "Name": "MD",
                     "Description": "MD",
-                    "Unit": 70
+                    "Unit": 70,
+                    "IsWorking": true
                 },
                 {
                     "Name": "HR",
                     "Description": "HR",
-                    "Unit": 132
+                    "Unit": 132,
+                    "IsWorking": true
                 },
                 {
                     "Name": "Acceleration",
                     "Description": "Acceleration",
-                    "Unit": 80
+                    "Unit": 80,
+                    "IsWorking": true
                 },
                 {
                     "Name": "AT",
                     "Description": "AT",
-                    "Unit": 27
+                    "Unit": 27,
+                    "IsWorking": true
                 },
                 {
                     "Name": "PS/ED",
                     "Description": "PS/ED",
-                    "Unit": 0
+                    "Unit": 0,
+                    "IsWorking": true
                 },
                 {
                     "Name": "ED/PS",
                     "Description": "ED/PS",
-                    "Unit": 0
+                    "Unit": 0,
+                    "IsWorking": true
                 },
                 {
                     "Name": "PI",
                     "Description": "PI",
-                    "Unit": 0
+                    "Unit": 0,
+                    "IsWorking": true
                 },
                 {
                     "Name": "PI(MD)",
                     "Description": "PI(MD)",
-                    "Unit": 0
+                    "Unit": 0,
+                    "IsWorking": true
                 },
                 {
                     "Name": "RI",
                     "Description": "RI",
-                    "Unit": 0
+                    "Unit": 0,
+                    "IsWorking": true
                 },
                 {
                     "Name": "RI(MD)",
                     "Description": "RI(MD)",
-                    "Unit": 0
+                    "Unit": 0,
+                    "IsWorking": true
                 },
                 {
                     "Name": "Max PG",
                     "Description": "PG Rel",
-                    "Unit": 110
+                    "Unit": 110,
+                    "IsWorking": true
                 },
                 {
                     "Name": "Vmax",
                     "Description": "Vmax",
-                    "Unit": 70
+                    "Unit": 70,
+                    "IsWorking": true
                 },
                 {
                     "Name": "Vmean",
                     "Description": "Vmean",
-                    "Unit": 70
+                    "Unit": 70,
+                    "IsWorking": true
                 },
                 {
                     "Name": "Peak PG",
                     "Description": "Peak PG",
-                    "Unit": 110
+                    "Unit": 110,
+                    "IsWorking": true
                 },
                 {
                     "Name": "VTI",
                     "Description": "VTI",
-                    "Unit": 10
+                    "Unit": 10,
+                    "IsWorking": true
                 },
                 {
                     "Name": "VTI(Mean)",
                     "Description": "VTI(Mean)",
-                    "Unit": 10
+                    "Unit": 10,
+                    "IsWorking": true
                 },
                 {
                     "Name": "MPG",
                     "Description": "Mean PG(Max Mode)",
-                    "Unit": 110
+                    "Unit": 110,
+                    "IsWorking": true
                 },
                 {
                     "Name": "MMPG",
                     "Description": "Mean PG(Mean Mode)",
-                    "Unit": 110
+                    "Unit": 110,
+                    "IsWorking": true
                 },
                 {
                     "Name": "Ti Env",
                     "Description": "E. Time",
-                    "Unit": 27
+                    "Unit": 27,
+                    "IsWorking": true
                 },
                 {
                     "Name": "Vel E",
                     "Description": "Vel E",
-                    "Unit": 70
+                    "Unit": 70,
+                    "IsWorking": true
                 },
                 {
                     "Name": "Vel A",
                     "Description": "Vel A",
-                    "Unit": 70
+                    "Unit": 70,
+                    "IsWorking": true
                 },
                 {
                     "Name": "V E/A",
                     "Description": "V E/A",
-                    "Unit": 0
+                    "Unit": 0,
+                    "IsWorking": true
                 },
                 {
                     "Name": "DT",
                     "Description": "DT",
-                    "Unit": 27
+                    "Unit": 27,
+                    "IsWorking": true
                 },
                 {
                     "Name": "PHT",
                     "Description": "PHT",
-                    "Unit": 27
+                    "Unit": 27,
+                    "IsWorking": true
                 },
                 {
                     "Name": "VA",
                     "Description": "VA",
-                    "Unit": 50
+                    "Unit": 50,
+                    "IsWorking": true
                 },
                 {
                     "Name": "A Dur",
                     "Description": "A Dur",
-                    "Unit": 27
+                    "Unit": 27,
+                    "IsWorking": true
                 },
                 {
                     "Name": "AT/DT",
                     "Description": "AT/DT",
-                    "Unit": 0
+                    "Unit": 0,
+                    "IsWorking": true
                 },
                 {
                     "Name": "AT/ET",
                     "Description": "AT/ET",
-                    "Unit": 0
+                    "Unit": 0,
+                    "IsWorking": true
                 },
                 {
                     "Name": "Trace",
                     "Description": "Trace",
-                    "Unit": 0
+                    "Unit": 0,
+                    "IsWorking": true
                 }
             ]
         },
@@ -559,157 +591,188 @@
                         {
                             "Name": "TAMEAN",
                             "Description": "Mean Vel(Mean Mode)",
-                            "Unit": 70
+                            "Unit": 70,
+                            "IsWorking": true
                         },
                         {
                             "Name": "PS",
                             "Description": "PS",
-                            "Unit": 70
+                            "Unit": 70,
+                            "IsWorking": true
                         },
                         {
                             "Name": "ED",
                             "Description": "ED",
-                            "Unit": 70
+                            "Unit": 70,
+                            "IsWorking": true
                         },
                         {
                             "Name": "MD",
                             "Description": "MD",
-                            "Unit": 70
+                            "Unit": 70,
+                            "IsWorking": true
                         },
                         {
                             "Name": "HR",
                             "Description": "HR",
-                            "Unit": 132
+                            "Unit": 132,
+                            "IsWorking": true
                         },
                         {
                             "Name": "Acceleration",
                             "Description": "Acceleration",
-                            "Unit": 80
+                            "Unit": 80,
+                            "IsWorking": true
                         },
                         {
                             "Name": "AT",
                             "Description": "AT",
-                            "Unit": 27
+                            "Unit": 27,
+                            "IsWorking": true
                         },
                         {
                             "Name": "PS/ED",
                             "Description": "PS/ED",
-                            "Unit": 0
+                            "Unit": 0,
+                            "IsWorking": true
                         },
                         {
                             "Name": "ED/PS",
                             "Description": "ED/PS",
-                            "Unit": 0
+                            "Unit": 0,
+                            "IsWorking": true
                         },
                         {
                             "Name": "PI",
                             "Description": "PI",
-                            "Unit": 0
+                            "Unit": 0,
+                            "IsWorking": true
                         },
                         {
                             "Name": "PI(MD)",
                             "Description": "PI(MD)",
-                            "Unit": 0
+                            "Unit": 0,
+                            "IsWorking": true
                         },
                         {
                             "Name": "RI",
                             "Description": "RI",
-                            "Unit": 0
+                            "Unit": 0,
+                            "IsWorking": true
                         },
                         {
                             "Name": "RI(MD)",
                             "Description": "RI(MD)",
-                            "Unit": 0
+                            "Unit": 0,
+                            "IsWorking": true
                         },
                         {
                             "Name": "Max PG",
                             "Description": "PG Rel",
-                            "Unit": 110
+                            "Unit": 110,
+                            "IsWorking": true
                         },
                         {
                             "Name": "Vmax",
                             "Description": "Vmax",
-                            "Unit": 70
+                            "Unit": 70,
+                            "IsWorking": true
                         },
                         {
                             "Name": "Vmean",
                             "Description": "Vmean",
-                            "Unit": 70
+                            "Unit": 70,
+                            "IsWorking": true
                         },
                         {
                             "Name": "Peak PG",
                             "Description": "Peak PG",
-                            "Unit": 110
+                            "Unit": 110,
+                            "IsWorking": true
                         },
                         {
                             "Name": "VTI",
                             "Description": "VTI",
-                            "Unit": 10
+                            "Unit": 10,
+                            "IsWorking": true
                         },
                         {
                             "Name": "VTI(Mean)",
                             "Description": "VTI(Mean)",
-                            "Unit": 10
+                            "Unit": 10,
+                            "IsWorking": true
                         },
                         {
                             "Name": "MPG",
                             "Description": "Mean PG(Max Mode)",
-                            "Unit": 110
+                            "Unit": 110,
+                            "IsWorking": true
                         },
                         {
                             "Name": "MMPG",
                             "Description": "Mean PG(Mean Mode)",
-                            "Unit": 110
+                            "Unit": 110,
+                            "IsWorking": true
                         },
                         {
                             "Name": "Ti Env",
                             "Description": "E. Time",
-                            "Unit": 27
+                            "Unit": 27,
+                            "IsWorking": true
                         },
                         {
                             "Name": "AT/DT",
                             "Description": "AT/DT",
-                            "Unit": 0
+                            "Unit": 0,
+                            "IsWorking": true
                         },
                         {
                             "Name": "AT/ET",
                             "Description": "AT/ET",
-                            "Unit": 0
+                            "Unit": 0,
+                            "IsWorking": true
                         },
                         {
                             "Name": "Vel E",
                             "Description": "Vel E",
-                            "Unit": 70
+                            "Unit": 70,
+                            "IsWorking": true
                         },
                         {
                             "Name": "Vel A",
                             "Description": "Vel A",
-                            "Unit": 70
+                            "Unit": 70,
+                            "IsWorking": true
                         },
                         {
                             "Name": "V E/A",
                             "Description": "V E/A",
-                            "Unit": 0
+                            "Unit": 0,
+                            "IsWorking": true
                         },
                         {
                             "Name": "DT",
                             "Description": "DT",
-                            "Unit": 27
+                            "Unit": 27,
+                            "IsWorking": true
                         },
                         {
                             "Name": "PHT",
                             "Description": "PHT",
-                            "Unit": 27
+                            "Unit": 27,
+                            "IsWorking": true
                         },
                         {
                             "Name": "VA",
                             "Description": "VA",
-                            "Unit": 50
+                            "Unit": 50,
+                            "IsWorking": true
                         },
                         {
                             "Name": "A Dur",
                             "Description": "A Dur",
-                            "Unit": 27
+                            "Unit": 27,
+                            "IsWorking": true
                         }
                     ]
                 },

+ 27 - 0
lib/process/calcuators/trace.dart

@@ -0,0 +1,27 @@
+import 'package:fis_measure/interfaces/process/items/terms.dart';
+import 'package:fis_measure/process/primitives/multi_method/multiple_trace.dart';
+import 'calculator.dart';
+
+class TraceCal extends Calculator<TraceItemAbstract, double> {
+  TraceCal(TraceItemAbstract ref) : super(ref);
+
+  @override
+  void calculate() {
+    if (ref.feature == null) return;
+
+    final feature = ref.feature!;
+    final viewport = feature.hostVisualArea!.viewport!;
+    final points = feature.innerPoints.map((e) => viewport.convert(e)).toList();
+
+    double fakeOutputDate = 0;
+    for (var output in ref.meta.outputs) {
+      if (output.name == MeasureTerms.Slope) {
+        feature.updateFloatValue(output, fakeOutputDate, output.unit);
+      } else if (output.name == MeasureTerms.Timespan) {
+        feature.updateFloatValue(output, fakeOutputDate, output.unit);
+      } else if (output.name == MeasureTerms.Distance) {
+        feature.updateFloatValue(output, fakeOutputDate, output.unit);
+      }
+    }
+  }
+}

+ 43 - 17
lib/process/primitives/multi_method/multiple_trace.dart

@@ -4,12 +4,11 @@ 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/visuals/visual_area.dart';
 import 'package:fis_measure/interfaces/process/workspace/point_info.dart';
+import 'package:fis_measure/process/calcuators/trace.dart';
 import 'package:fis_measure/process/items/item.dart';
 import 'package:fis_measure/process/items/item_feature.dart';
 import 'package:fis_measure/utils/canvas.dart';
-import 'package:path_drawing/path_drawing.dart';
 
 /// 手势轨迹图形
 class MultiTrace extends TraceItemAbstract {
@@ -85,7 +84,6 @@ class MultiTrace extends TraceItemAbstract {
       if (args.pointType == PointInfoType.touchMove) {
         feature?.adopt(args);
         doCalculate();
-        // checkAutoSnap(args);
       }
     }
     return true;
@@ -96,8 +94,7 @@ class MultiTrace extends TraceItemAbstract {
     IMeasureItem? parent,
   ]) {
     MultiTrace trace = MultiTrace(meta, parent);
-    // trace.calculator = CurveLengthCal(trace);
-    trace.isFinished = false;
+    trace.calculator = TraceCal(trace);
     return trace;
   }
 }
@@ -164,36 +161,65 @@ abstract class TraceItemFeatureAbstract extends MeasureItemFeature {
   DPoint get startPoint => innerPoints.first;
   DPoint get endPoint => innerPoints.last;
 
+  bool ifRightSide = true;
+
   /// 接收新坐标
   void adopt(DPoint point) {
     if (innerPoints.isEmpty) {
       innerPoints.add(point);
     }
-    if (point.x < innerPoints.last.x) {
-      clearRight(point.x);
+    if (point.x > startPoint.x) {
+      handleChangeSide(point);
+      if (point.x < innerPoints.last.x) {
+        clearRight(point.x);
+      } else {
+        innerPoints.add(point);
+      }
     } else {
-      innerPoints.add(point);
+      handleChangeSide(point);
+      if (point.x > innerPoints.last.x) {
+        clearLeft(point.x);
+      } else {
+        innerPoints.add(point);
+      }
     }
   }
 
   void clearRight(double X) {
     if (innerPoints.isEmpty) return;
     for (var i = innerPoints.length - 1; i >= 0; i--) {
-      if (innerPoints[i].x > X) {
+      if (innerPoints[i].x >= X) {
         innerPoints.removeAt(i);
       }
     }
   }
-}
 
-abstract class TraceItemAbstract extends MeasureItem<TraceItemFeatureAbstract> {
-  bool _isFinished = false;
-  TraceItemAbstract(ItemMeta meta, IMeasureItem? parent) : super(meta, parent);
+  void clearLeft(double X) {
+    if (innerPoints.isEmpty) return;
+    for (var i = innerPoints.length - 1; i >= 0; i--) {
+      if (innerPoints[i].x <= X) {
+        innerPoints.removeAt(i);
+      }
+    }
+  }
 
-  bool get isFinished => _isFinished;
-  set isFinished(bool val) {
-    if (val != _isFinished) {
-      _isFinished = val;
+  void handleChangeSide(point) {
+    if (ifRightSide) {
+      if (point.x < startPoint.x) {
+        ifRightSide = false;
+        innerPoints.clear();
+        innerPoints.add(point);
+      }
+    } else {
+      if (point.x > startPoint.x) {
+        ifRightSide = true;
+        innerPoints.clear();
+        innerPoints.add(point);
+      }
     }
   }
 }
+
+abstract class TraceItemAbstract extends MeasureItem<TraceItemFeatureAbstract> {
+  TraceItemAbstract(ItemMeta meta, IMeasureItem? parent) : super(meta, parent);
+}