Browse Source

支持Afi四线测量

melon.yin 2 years ago
parent
commit
4085369b99

+ 1 - 0
lib/item_create_test.dart

@@ -105,6 +105,7 @@ class TestItems {
     MeasureTerms.CervixL,
     MeasureTerms.CervixW,
     MeasureTerms.CervixH,
+    "AFI",
     "Tumor Cervix",
     "AxT",
     "FTA",

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

@@ -2,6 +2,7 @@ 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/types.dart';
 import 'package:fis_measure/process/items/item.dart';
+import 'package:fis_measure/process/primitives/combos/afi.dart';
 import 'package:fis_measure/process/primitives/combos/area_straightline.dart';
 import 'package:fis_measure/process/primitives/combos/depth2baseline.dart';
 import 'package:fis_measure/process/primitives/combos/lwh_straightline.dart';
@@ -146,5 +147,8 @@ class MeasureItemFactory {
         MeasureTypes.CurveLengthSpline, Spline.createCurveLength);
     _singleton._register(
         MeasureTypes.CurveLengthTrace, Trace.createCurveLength);
+
+    // Specific
+    _singleton._register(MeasureTypes.Afi, Afi.createAfi);
   }
 }

+ 27 - 0
lib/process/items/top_item.dart

@@ -1,6 +1,7 @@
 import 'package:fis_common/event/event_type.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/workspace/point_info.dart';
 import 'package:flutter/foundation.dart';
 
 import 'item.dart';
@@ -37,6 +38,32 @@ abstract class TopMeasureItem<T extends MeasureItemFeature>
     workingChildChanged.emit(this, index);
   }
 
+  T buildFeature();
+
+  @override
+  bool onExecuteMouse(PointInfo args) {
+    if (args.pointType == PointInfoType.mouseDown) {
+      if (feature == null) {
+        feature = buildFeature();
+        listenChildrenUpdate();
+      }
+      if (childrenAllDone) {
+        workingChild.clear();
+      }
+    }
+    feature?.hostVisualArea = args.hostVisualArea;
+    final result = workingChild.execute(args);
+    if (result) {
+      doCalculate();
+    }
+    return result;
+  }
+
+  @override
+  bool onExecuteTouch(PointInfo args) {
+    return workingChild.execute(args);
+  }
+
   @protected
   void nextChild() {
     final count = _childItems.length;

+ 86 - 0
lib/process/primitives/combos/afi.dart

@@ -0,0 +1,86 @@
+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/workspace/point_info.dart';
+import 'package:fis_measure/process/calcuators/calculator.dart';
+import 'package:fis_measure/process/items/top_item.dart';
+import 'package:fis_measure/process/items/top_item_feature.dart';
+import 'package:fis_measure/process/primitives/straightline.dart';
+import 'package:vid/us/vid_us_unit.dart';
+
+class Afi extends TopMeasureItem<AfiFeature> {
+  static const String _lineQ1Key = "Q1";
+  static const String _lineQ2Key = "Q2";
+  static const String _lineQ3Key = "Q3";
+  static const String _lineQ4Key = "Q4";
+
+  late final StraightLine q1;
+  late final StraightLine q2;
+  late final StraightLine q3;
+  late final StraightLine q4;
+
+  Afi(ItemMeta meta) : super(meta) {
+    final metaQ1 = meta.getChildByName(_lineQ1Key)!;
+    final metaQ2 = meta.getChildByName(_lineQ2Key)!;
+    final metaQ3 = meta.getChildByName(_lineQ3Key)!;
+    final metaQ4 = meta.getChildByName(_lineQ4Key)!;
+    q1 = StraightLine.createDistance(metaQ1, this);
+    q2 = StraightLine.createDistance(metaQ2, this);
+    q3 = StraightLine.createDistance(metaQ3, this);
+    q4 = StraightLine.createDistance(metaQ4, this);
+    childItems.add(q1);
+    childItems.add(q2);
+    childItems.add(q3);
+    childItems.add(q4);
+  }
+
+  @override
+  AfiFeature buildFeature() => AfiFeature(this);
+
+  static Afi createAfi(ItemMeta meta, [IMeasureItem? parent]) {
+    final afi = Afi(meta);
+    afi.calculator = AfiSumCal(afi);
+    return afi;
+  }
+}
+
+class AfiFeature extends TopMeasureItemFeature {
+  AfiFeature(Afi refItem) : super(refItem);
+}
+
+class AfiSumCal extends Calculator<Afi, double> {
+  AfiSumCal(Afi ref) : super(ref);
+
+  @override
+  void calculate() {
+    if (ref.feature == null) return;
+
+    final vQ1 = findChildFeature(ref.q1)?.value;
+    final vQ2 = findChildFeature(ref.q2)?.value;
+    final vQ3 = findChildFeature(ref.q3)?.value;
+    final vQ4 = findChildFeature(ref.q4)?.value;
+
+    double q1 = 0;
+    double q2 = 0;
+    double q3 = 0;
+    double q4 = 0;
+    VidUsUnit unit = VidUsUnit.None;
+    if (vQ1 != null) {
+      q1 = vQ1.pickFloat()!;
+      unit = vQ1.unit;
+    }
+    if (vQ2 != null) {
+      q2 = vQ2.pickFloat()!;
+      unit = vQ2.unit;
+    }
+    if (vQ3 != null) {
+      q3 = vQ3.pickFloat()!;
+      unit = vQ3.unit;
+    }
+    if (vQ4 != null) {
+      q4 = vQ4.pickFloat()!;
+      unit = vQ4.unit;
+    }
+    final afi = q1 + q2 + q3 + q4;
+    updateFloatValue(afi, unit: unit, useRound: true);
+  }
+}

+ 1 - 22
lib/process/primitives/combos/area_straightline.dart

@@ -27,28 +27,7 @@ class AreaStraightLine extends TopMeasureItem<AreaStraightLineFeature> {
   }
 
   @override
-  bool onExecuteMouse(PointInfo args) {
-    if (args.pointType == PointInfoType.mouseDown) {
-      if (feature == null) {
-        feature = AreaStraightLineFeature(this);
-        listenChildrenUpdate();
-      }
-      if (childrenAllDone) {
-        workingChild.clear();
-      }
-    }
-    feature?.hostVisualArea = args.hostVisualArea;
-    final result = workingChild.execute(args);
-    if (result) {
-      doCalculate();
-    }
-    return result;
-  }
-
-  @override
-  bool onExecuteTouch(PointInfo args) {
-    return workingChild.execute(args);
-  }
+  AreaStraightLineFeature buildFeature() => AreaStraightLineFeature(this);
 
   static AreaStraightLine createVolume(ItemMeta meta, [IMeasureItem? parent]) {
     if (meta.measureType != MeasureTypes.AreaStraightLine) {

+ 1 - 23
lib/process/primitives/combos/depth2baseline.dart

@@ -29,29 +29,7 @@ class DepthToBaseLine extends TopMeasureItem<DepthToBaseLineFeature> {
   }
 
   @override
-  bool onExecuteMouse(PointInfo args) {
-    if (feature == null) {
-      feature = DepthToBaseLineFeature(this);
-      listenChildrenUpdate();
-    }
-
-    if (args.pointType == PointInfoType.mouseDown) {
-      if (childrenAllDone) {
-        workingChild.clear();
-      }
-    }
-    feature?.hostVisualArea = args.hostVisualArea;
-    final result = workingChild.execute(args);
-    if (result) {
-      doCalculate();
-    }
-    return result;
-  }
-
-  @override
-  bool onExecuteTouch(PointInfo args) {
-    return workingChild.execute(args);
-  }
+  DepthToBaseLineFeature buildFeature() => DepthToBaseLineFeature(this);
 
   static DepthToBaseLine createDepthToBaseLine(ItemMeta meta,
       [IMeasureItem? parent]) {

+ 1 - 22
lib/process/primitives/combos/lwh_straightline.dart

@@ -32,28 +32,7 @@ class LWHStraightLine extends TopMeasureItem<LWHStraightlineFeature> {
   }
 
   @override
-  bool onExecuteMouse(PointInfo args) {
-    if (args.pointType == PointInfoType.mouseDown) {
-      if (feature == null) {
-        feature = LWHStraightlineFeature(this);
-        listenChildrenUpdate();
-      }
-      if (childrenAllDone) {
-        workingChild.clear();
-      }
-    }
-    feature?.hostVisualArea = args.hostVisualArea;
-    final result = workingChild.execute(args);
-    if (result) {
-      doCalculate();
-    }
-    return result;
-  }
-
-  @override
-  bool onExecuteTouch(PointInfo args) {
-    return workingChild.execute(args);
-  }
+  LWHStraightlineFeature buildFeature() => LWHStraightlineFeature(this);
 
   @override
   void onCancelingOnce() {}

+ 1 - 22
lib/process/primitives/combos/two_area.dart

@@ -38,28 +38,7 @@ class TwoArea extends TwoLengthAbstract<TwoAreaFeature> {
   Trace get child2 => a2;
 
   @override
-  bool onExecuteMouse(PointInfo args) {
-    if (args.pointType == PointInfoType.mouseDown) {
-      if (feature == null) {
-        feature = TwoAreaFeature(this);
-        listenChildrenUpdate();
-      }
-      if (childrenAllDone) {
-        workingChild.clear();
-      }
-    }
-    feature?.hostVisualArea = args.hostVisualArea;
-    final result = workingChild.execute(args);
-    if (result) {
-      doCalculate();
-    }
-    return result;
-  }
-
-  @override
-  bool onExecuteTouch(PointInfo args) {
-    return workingChild.execute(args);
-  }
+  TwoAreaFeature buildFeature() => TwoAreaFeature(this);
 
   @override
   void onCancelingOnce() {}

+ 1 - 22
lib/process/primitives/combos/two_straightline.dart

@@ -36,28 +36,7 @@ class TwoStraightLine extends TwoLengthAbstract<TwoStraightLineFeature> {
   StraightLine get child2 => y;
 
   @override
-  bool onExecuteMouse(PointInfo args) {
-    if (args.pointType == PointInfoType.mouseDown) {
-      if (feature == null) {
-        feature = TwoStraightLineFeature(this);
-        listenChildrenUpdate();
-      }
-      if (childrenAllDone) {
-        workingChild.clear();
-      }
-    }
-    feature?.hostVisualArea = args.hostVisualArea;
-    final result = workingChild.execute(args);
-    if (result) {
-      doCalculate();
-    }
-    return result;
-  }
-
-  @override
-  bool onExecuteTouch(PointInfo args) {
-    return workingChild.execute(args);
-  }
+  TwoStraightLineFeature buildFeature() => TwoStraightLineFeature(this);
 
   @override
   void onCancelingOnce() {}