Browse Source

measure depth on convex_tissue

melon.yin 2 years ago
parent
commit
c2b4fc47a9
5 changed files with 43 additions and 20 deletions
  1. 19 9
      lib/main.dart
  2. 12 7
      lib/process/calcuators/depth.dart
  3. 6 3
      lib/process/primitives/location.dart
  4. 1 1
      pubspec.lock
  5. 5 0
      pubspec.yaml

+ 19 - 9
lib/main.dart

@@ -1,17 +1,13 @@
-import 'dart:io';
+import 'dart:ui';
 import 'package:fis_measure/measure_page_test.dart';
-import 'package:fis_measure/process/workspace/measure_controller.dart';
-import 'package:flutter/foundation.dart';
 import 'package:flutter/material.dart';
 import 'package:get/get.dart';
-
-import 'view/gesture/mouse_gesture.dart';
-import 'view/player/player.dart';
+import 'package:fis_i18n/i18n.dart';
 import 'vid.dart';
-import 'vid_player_mtest.dart';
-import 'vid_player_test.dart';
 
-void main() {
+void main() async {
+  WidgetsFlutterBinding.ensureInitialized();
+  await _initI18n();
   runApp(const MyApp());
 }
 
@@ -157,3 +153,17 @@ class _MyHomePageState extends State<MyHomePage> {
     );
   }
 }
+
+Future<void> _initI18n() async {
+  final curLocale = window.locale;
+
+  var bookOptions = [
+    FTrKeybookOption.ChineseOption,
+    FTrKeybookOption.EnglishOption,
+  ];
+
+  await FI18n.init((locale) => Get.updateLocale(locale), bookOptions);
+  await FI18n.load(curLocale);
+
+  Get.put(FI18n.ins);
+}

+ 12 - 7
lib/process/calcuators/depth.dart

@@ -42,19 +42,24 @@ class TissueConvexDepthCal extends Calculator<Location, double> {
     // TODO:xxx
     final viewport = ref.feature!.hostVisualArea!.viewport!;
     final physical = viewport.physical! as ConvexTissuePhysicalCoordinate;
-    final point = ref.feature!.innerPoints.first;
+    final point = ref.feature!.point;
+
     final physicalPoint = viewport.convert(point);
-    final convertedPoint = physical.convert(physicalPoint);
-    final zeroPoint = DPoint(viewport.region.width / 2, physical.zeroY);
-    final depth = (convertedPoint - zeroPoint).length;
+    final physicalZeroPoint = DPoint(viewport.region.width / 2, physical.zeroY);
+    final distance = (physicalPoint - physicalZeroPoint).length;
+    final depth = distance - physical.zeroRadius;
 
+    final valueDesc =
+        depth < 0 ? '' : '${roundDouble(depth)}${VidUsUnit.cm.name}';
+    final description = "${ref.description}: $valueDesc";
+
+    final double outputValue = depth < 0 ? 0 : depth;
     final outputItem = OutputItem(
-      value: depth,
+      value: outputValue,
       name: MeasureTerms.Depth,
       unit: VidUsUnit.cm,
     );
-    final description =
-        "${ref.description}: ${roundDouble(depth)}${VidUsUnit.cm.name}";
+
     outputItem.updateDescription(description: description);
     output = outputItem;
   }

+ 6 - 3
lib/process/primitives/location.dart

@@ -91,9 +91,11 @@ class TissueConvexLocationFeature extends LocationFeature {
     final physical = (viewport.physical! as ConvexTissuePhysicalCoordinate);
     final region = viewport.region;
 
-    final physicalZeroPoint = DPoint(region.width / 2, physical.zeroY);
+    final physicalZeroPoint =
+        DPoint(region.width / 2, physical.zeroY); // 真实尺寸圆心
+
     final physicalPoint = viewport.convert(point);
-    final physicalStartPoint = _findRegionPoint(
+    final physicalStartPoint = _findCrossPointOnInnerDiameter(
       physicalZeroPoint,
       physicalPoint,
       physical.zeroRadius,
@@ -111,7 +113,8 @@ class TissueConvexLocationFeature extends LocationFeature {
     super.paint(canvas, size);
   }
 
-  DPoint? _findRegionPoint(
+  /// 找到直线(圆心到当前点)和扇形内圈的交叉点
+  DPoint? _findCrossPointOnInnerDiameter(
     DPoint zero,
     DPoint point,
     double zeroRadius,

+ 1 - 1
pubspec.lock

@@ -123,7 +123,7 @@ packages:
     source: git
     version: "0.0.2"
   fis_i18n:
-    dependency: "direct overridden"
+    dependency: "direct main"
     description:
       path: "."
       ref: a9ade48f4d

+ 5 - 0
pubspec.yaml

@@ -54,6 +54,11 @@ dependencies:
   path_drawing: ^1.0.0
   image: 3.1.3
 
+  fis_i18n:
+    git:
+      url: http://git.ius.plus:88/Project-Wing/fis_lib_i18n.git
+      ref: a9ade48f4d
+
 dependency_overrides:
   fis_common:
     git: