Эх сурвалжийг харах

update(measure): 完成 M 模式下的 %Stenosis

gavin.chen 2 жил өмнө
parent
commit
086ab6cf99

+ 73 - 0
assets/items.json

@@ -1,4 +1,77 @@
 [
+    {
+        "Name": "%Stenosis",
+        "Description": "%Stenosis",
+        "BriefAnnotation": "",
+        "MeasureTypeName": "StenosisTwoVerticalDistance",
+        "Categories": [
+            "Common"
+        ],
+        "Calculator": {
+            "AvailableOutputs": [
+                {
+                    "Name": "%Stenosis",
+                    "Description": "%Stenosis",
+                    "Unit": 1,
+                    "IsWorking": true
+                }
+            ]
+        },
+        "MultiMethodItems": [
+            {
+                "Name": "Diam",
+                "IsWorking": true,
+                "ChildItems": [
+                    {
+                        "Name": "L1",
+                        "Description": "D1",
+                        "IsWorking": true,
+                        "ChildItems": [],
+                        "Calculator": {
+                            "AvailableOutputs": [
+                                {
+                                    "Name": "Distance",
+                                    "Description": "Distance",
+                                    "Unit": 10,
+                                    "IsWorking": true
+                                }
+                            ]
+                        },
+                        "MeasureTypeName": "VerticalDistance"
+                    },
+                    {
+                        "Name": "L2",
+                        "Description": "D2",
+                        "IsWorking": true,
+                        "ChildItems": [],
+                        "Calculator": {
+                            "AvailableOutputs": [
+                                {
+                                    "Name": "Distance",
+                                    "Description": "Distance",
+                                    "Unit": 10,
+                                    "IsWorking": true
+                                }
+                            ]
+                        },
+                        "MeasureTypeName": "VerticalDistance"
+                    }
+                ],
+                "Calculator": {
+                    "AvailableOutputs": [
+                        {
+                            "Name": "%Stenosis",
+                            "Description": "%Stenosis",
+                            "Unit": 1,
+                            "IsWorking": true
+                        }
+                    ]
+                },
+                "MeasureTypeName": "StenosisTwoDistance"
+            }
+        ],
+        "MethodChildItems": []
+    },
     {
         "Name": "Depth",
         "Description": "Depth",

+ 1 - 0
lib/measure_page_test.dart

@@ -364,6 +364,7 @@ class _MeasureLeftBoardState extends State<_MeasureLeftBoard> {
     MeasureTerms.VerticalDistance,
     MeasureTerms.Timespan,
     MeasureTerms.Depth,
+    MeasureTerms.Stenosis,
     "Qp/Qs",
   ];
 

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

@@ -1,3 +1,8 @@
+import 'package:fis_measure/interfaces/process/calculators/values.dart';
+import 'package:fis_measure/process/calcuators/formulas/general.dart';
+import 'package:fis_measure/process/items/item.dart';
+import 'package:fis_measure/process/primitives/combos/two_length.dart';
+
 import '../primitives/straightline.dart';
 import 'calculator.dart';
 
@@ -38,3 +43,40 @@ class TimeSpanCal extends Calculator<StraightLine, double> {
     updateFloatValue(value);
   }
 }
+
+class StenosisCal extends Calculator<TwoLengthAbstract, double> {
+  StenosisCal(TwoLengthAbstract ref) : super(ref);
+
+  @override
+  void calculate() {
+    if (ref.feature == null) return;
+
+    final a1 = _pickChildValue(ref.child1);
+    final a2 = _pickChildValue(ref.child2);
+
+    final feature = ref.feature!;
+    final viewport = feature.hostVisualArea!.viewport!;
+
+    if (a1 != null && a2 != null) {
+      final value = GeneralFormulas.countStenosis(
+        a1,
+        a2,
+      );
+      updateFloatValue(value);
+    }
+  }
+
+  double? _pickChildValue(MeasureItem item) {
+    if (item.calculator == null) return null;
+    ValueBase? value;
+    if (item.measuredFeatures.isNotEmpty) {
+      value = item.measuredFeatures.first.value;
+    } else if (item.feature != null) {
+      value = item.feature!.value;
+    }
+    if (value != null) {
+      return (value as FloatValue).value ?? 0;
+    }
+    return null;
+  }
+}

+ 3 - 1
lib/process/items/factory.dart

@@ -69,7 +69,6 @@ class MeasureItemFactory {
   static void _registerItemCreators() {
     _singleton._register(MeasureTypes.Distance, StraightLine.createDistance);
     _singleton._register(MeasureTypes.Depth, Location.createTissueDepth);
-    _singleton._register(MeasureTypes.MDepth, Location.createTissueTMDepth);
 
     // Three StraightLine
     _singleton._register(
@@ -94,6 +93,9 @@ class MeasureItemFactory {
     _singleton._register(
         MeasureTypes.VerticalDistance, StraightLine.createVerticalDistance);
     _singleton._register(MeasureTypes.TimeSpan, StraightLine.createTimeSpan);
+    _singleton._register(MeasureTypes.MDepth, Location.createTissueTMDepth);
+    _singleton._register(MeasureTypes.StenosisTwoVerticalDistance,
+        TwoStraightLine.createStenosisTwoVerticalDistance);
 
     // Area Perimeter
     _singleton._register(

+ 18 - 3
lib/process/primitives/combos/two_straightline.dart

@@ -20,12 +20,19 @@ import 'two_length.dart';
 class TwoStraightLine extends TwoLengthAbstract<TwoStraightLineFeature> {
   late final StraightLine x;
   late final StraightLine y;
+  final bool ifVertical;
 
-  TwoStraightLine(ItemMeta meta) : super(meta) {
+  TwoStraightLine(ItemMeta meta, {this.ifVertical = false}) : super(meta) {
     final metaX = meta.childItems[0];
     final metaY = meta.childItems[1];
-    x = StraightLine.createDistance(metaX, this);
-    y = StraightLine.createDistance(metaY, this);
+
+    if (ifVertical) {
+      x = StraightLine.createDistance(metaX, this);
+      y = StraightLine.createDistance(metaY, this);
+    } else {
+      x = StraightLine.createVerticalDistance(metaX, this);
+      y = StraightLine.createVerticalDistance(metaY, this);
+    }
     childItems.add(x);
     childItems.add(y);
   }
@@ -83,6 +90,14 @@ class TwoStraightLine extends TwoLengthAbstract<TwoStraightLineFeature> {
 
     return twoStraightline;
   }
+
+  static TwoStraightLine createStenosisTwoVerticalDistance(ItemMeta meta,
+      [IMeasureItem? parent]) {
+    var twoStraightline = TwoStraightLine(meta, ifVertical: true);
+    twoStraightline.calculator = StenosisCal(twoStraightline);
+
+    return twoStraightline;
+  }
 }
 
 class TwoStraightLineFeature extends TopMeasureItemFeature {