Kaynağa Gözat

update(measure): support SlopeDoppler

gavin.chen 2 yıl önce
ebeveyn
işleme
89b008bffa

+ 33 - 0
assets/items.json

@@ -1,4 +1,37 @@
 [
+    {
+        "Name": "Acceleration",
+        "Description": "Acceleration",
+        "BriefAnnotation": "",
+        "MeasureTypeName": "SlopeDoppler",
+        "Categories": [
+            "Common"
+        ],
+        "Calculator": {
+            "AvailableOutputs": [
+                {
+                    "Name": "Slope",
+                    "Description": "Slope",
+                    "Unit": 70,
+                    "IsWorking": true
+                },
+                {
+                    "Name": "Timespan",
+                    "Description": "Time",
+                    "Unit": 20,
+                    "IsWorking": true
+                },
+                {
+                    "Name": "Distance",
+                    "Description": "Distance",
+                    "Unit": 10,
+                    "IsWorking": true
+                }
+            ]
+        },
+        "MultiMethodItems": [],
+        "MethodChildItems": []
+    },
     {
         "Name": "Velocity",
         "Description": "Velocity",

+ 1 - 0
lib/interfaces/process/items/types.dart

@@ -130,4 +130,5 @@ class MeasureTypes {
   /* Doppler */
   static const SemiManualTrace = "SemiManualTrace";
   static const DopplerTrace = "DopplerTrace";
+  static const SlopeDoppler = "SlopeDoppler";
 }

+ 1 - 0
lib/measure_page_test.dart

@@ -370,6 +370,7 @@ class _MeasureLeftBoardState extends State<_MeasureLeftBoard> {
     MeasureTerms.Slope,
     MeasureTerms.TAMAX,
     MeasureTerms.Velocity,
+    MeasureTerms.Acceleration,
     "Qp/Qs",
   ];
 

+ 30 - 0
lib/process/calcuators/time_motion.dart

@@ -115,3 +115,33 @@ class SlopeCal extends Calculator<StraightLine, double> {
     }
   }
 }
+
+class SlopeDopplerCal extends Calculator<StraightLine, double> {
+  SlopeDopplerCal(StraightLine ref) : super(ref);
+
+  @override
+  void calculate() {
+    if (ref.feature == null) return;
+
+    final feature = ref.feature!;
+    final viewport = feature.hostVisualArea!.viewport!;
+    final p1 = feature.startPoint;
+    final p2 = feature.endPoint;
+    final pp1 = viewport.convert(p1);
+    final pp2 = viewport.convert(p2);
+
+    final distance = (pp2.y - pp1.y).abs();
+    final time = (pp2.x - pp1.x).abs();
+
+    for (var output in ref.meta.outputs) {
+      if (output.name == MeasureTerms.Slope) {
+        var slope = GeneralFormulas.countSlope(pp2, pp1);
+        feature.updateFloatValue(output, slope, output.unit);
+      } else if (output.name == MeasureTerms.Timespan) {
+        feature.updateFloatValue(output, time, output.unit);
+      } else if (output.name == MeasureTerms.Distance) {
+        feature.updateFloatValue(output, distance, output.unit);
+      }
+    }
+  }
+}

+ 2 - 0
lib/process/items/factory.dart

@@ -128,6 +128,8 @@ class MeasureItemFactory {
     _singleton._register(MeasureTypes.AbRatioTwoVerticalDistance,
         TwoStraightLine.createAbRatioTwoVerticalDistance);
     _singleton._register(MeasureTypes.Slope, StraightLine.createSlope);
+    _singleton._register(
+        MeasureTypes.SlopeDoppler, StraightLine.createSlopeDoppler);
     _singleton._register(MeasureTypes.Velocity, Location.createVelocity);
     _singleton._register(MeasureTypes.DopplerTrace, MultiTrace.createTrace);
 

+ 10 - 0
lib/process/primitives/straightline.dart

@@ -37,6 +37,13 @@ class StraightLine extends MeasureItem<StraightLineFeature> {
     return sraightLine;
   }
 
+  static StraightLine createSlopeDoppler(ItemMeta meta,
+      [IMeasureItem? parent]) {
+    StraightLine sraightLine = StraightLine(meta, parent);
+    sraightLine.calculator = SlopeDopplerCal(sraightLine);
+    return sraightLine;
+  }
+
   static StraightLine createVerticalDistance(ItemMeta meta,
       [IMeasureItem? parent]) {
     StraightLine sraightLine = StraightLine(meta, parent);
@@ -144,6 +151,9 @@ class StraightLine extends MeasureItem<StraightLineFeature> {
         case MeasureTypes.Slope:
           feature = StraightLineSlopeFeature(this, point, point);
           break;
+        case MeasureTypes.SlopeDoppler:
+          feature = StraightLineSlopeFeature(this, point, point);
+          break;
         default:
       }
     } else {