浏览代码

1、修复ai编辑无法改变病灶大小的问题

guanxinyi 1 年之前
父节点
当前提交
90e2ebafb9
共有 1 个文件被更改,包括 12 次插入18 次删除
  1. 12 18
      lib/view/ai_result_modifier/controller.dart

+ 12 - 18
lib/view/ai_result_modifier/controller.dart

@@ -932,25 +932,19 @@ class AiResultModifierController extends GetxController {
     final p2 = keyPoints[pIndexs[1]].point!;
     final p3 = keyPoints[pIndexs[2]].point!;
     final p4 = keyPoints[pIndexs[3]].point!;
-    AIDiagnosisLesionSize currLesionSize = AIDiagnosisLesionSize();
-    List<AIDiagnosisDescription>? descriptions = modifiedDataDTO
-        .diagResultsForEachOrgan![0]
-        .detectedObjects![currentAiDetectedObjectIndex]
-        .descriptions;
-    //遍历 descriptions 取出病灶大小
-    //Descriptions 为空属于非正常数据
-    if (descriptions!.isEmpty) {
-      return;
-    }
-    for (AIDiagnosisDescription description in descriptions) {
-      if (description.type == DiagnosisDescriptionEnum.LesionSize) {
-        currLesionSize =
-            AIDiagnosisLesionSize.fromJson(jsonDecode(description.value ?? ""));
-      }
-    }
-    _horizontalLengthInPixel = currLesionSize.horizontalLengthInPixel;
-    _verticalLengthInPixel = currLesionSize.verticalLengthInPixel;
 
+    /// 计算 p1 到 p2 的像素距离 更新到 _horizontalLengthInPixel
+    /// 计算 p3 到 p4 的像素距离 更新到 _verticalLengthInPixel
+    double _horizontalLength =
+        (Offset(p1.x.toInt().toDouble(), p1.y.toInt().toDouble()) -
+                Offset(p2.x.toInt().toDouble(), p2.y.toInt().toDouble()))
+            .distance;
+    _horizontalLengthInPixel = _horizontalLength.ceil();
+    double _verticalLength =
+        (Offset(p3.x.toInt().toDouble(), p3.y.toInt().toDouble()) -
+                Offset(p4.x.toInt().toDouble(), p4.y.toInt().toDouble()))
+            .distance;
+    _verticalLengthInPixel = _verticalLength.ceil();
     lesionSize = _getNewLesionSize(
         [p1, p2, p3, p4], _horizontalLengthInPixel, _verticalLengthInPixel);
     update(['ai_result_lesion_size', 'ai_result_lesion_ratio']);