Browse Source

fix autosnap

melon.yin 2 years ago
parent
commit
57f4d88d7e

+ 0 - 5
lib/process/calcuators/area.dart

@@ -21,11 +21,6 @@ class TraceAreaCal extends Calculator<Trace, double> {
         ref.feature!.innerPoints.map((e) => viewport.convert(e)).toList();
         ref.feature!.innerPoints.map((e) => viewport.convert(e)).toList();
 
 
     double value = clacArea(points);
     double value = clacArea(points);
-    final outputItem = createOutput(MeasureTypes.Area, value, VidUsUnit.cm2);
-    final description = "${ref.description}: ${roundDouble(value)}cm²";
-    outputItem.updateDescription(description: description);
-    output = outputItem;
-
     updateFloatValue(value);
     updateFloatValue(value);
   }
   }
 
 

+ 0 - 15
lib/process/calcuators/depth.dart

@@ -19,13 +19,6 @@ class TissueDepthCal extends Calculator<Location, double> {
     final point = ref.feature!.innerPoints.first;
     final point = ref.feature!.innerPoints.first;
     final physicalPoint = viewport.physical!.convert(point);
     final physicalPoint = viewport.physical!.convert(point);
     final value = physicalPoint.y * viewport.region.height;
     final value = physicalPoint.y * viewport.region.height;
-
-    final outputItem = createOutput(MeasureTypes.Depth, value, VidUsUnit.cm);
-    final description =
-        "${ref.description}: ${roundDouble(value)}${VidUsUnit.cm.name}";
-    outputItem.updateDescription(description: description);
-    output = outputItem;
-
     updateFloatValue(value);
     updateFloatValue(value);
   }
   }
 }
 }
@@ -50,15 +43,7 @@ class TissueConvexDepthCal extends Calculator<Location, double> {
     final distance = (physicalPoint - physicalZeroPoint).length;
     final distance = (physicalPoint - physicalZeroPoint).length;
     final depth = distance - physical.zeroRadius;
     final depth = distance - physical.zeroRadius;
 
 
-    final valueDesc =
-        depth < 0 ? '' : '${roundDouble(depth)}${VidUsUnit.cm.name}';
-    final description = "${ref.description}: $valueDesc";
-
     final double value = depth < 0 ? 0 : depth;
     final double value = depth < 0 ? 0 : depth;
-    final outputItem = createOutput(MeasureTypes.Depth, value, VidUsUnit.cm);
-
-    outputItem.updateDescription(description: description);
-    output = outputItem;
     updateFloatValue(value);
     updateFloatValue(value);
   }
   }
 }
 }

+ 0 - 11
lib/process/calcuators/distance.dart

@@ -20,19 +20,8 @@ class DistanceCal extends Calculator<StraightLine, double> {
     final p2 = feature.endPoint;
     final p2 = feature.endPoint;
     final pp1 = viewport.convert(p1);
     final pp1 = viewport.convert(p1);
     final pp2 = viewport.convert(p2);
     final pp2 = viewport.convert(p2);
-    // final pp1 =
-    //     DPoint(p1.x * viewport.region.width, p1.y * viewport.region.height);
-    // final pp2 =
-    //     DPoint(p2.x * viewport.region.width, p2.y * viewport.region.height);
 
 
     final value = (pp2 - pp1).length.abs();
     final value = (pp2 - pp1).length.abs();
-    // final value =  ref.feature!.length;
-    final outputItem = createOutput(MeasureTypes.Distance, value, VidUsUnit.cm);
-    final description =
-        "${ref.description}: ${roundDouble(value)}${VidUsUnit.cm.name}";
-    outputItem.updateDescription(description: description);
-    output = outputItem;
-
     updateFloatValue(value);
     updateFloatValue(value);
   }
   }
 }
 }

+ 0 - 9
lib/process/calcuators/perimeter.dart

@@ -1,9 +1,6 @@
 import 'package:fis_measure/interfaces/date_types/point.dart';
 import 'package:fis_measure/interfaces/date_types/point.dart';
-import 'package:fis_measure/interfaces/process/calculators/output.dart';
 import 'package:fis_measure/interfaces/process/items/types.dart';
 import 'package:fis_measure/interfaces/process/items/types.dart';
 import 'package:fis_measure/process/primitives/ellipse.dart';
 import 'package:fis_measure/process/primitives/ellipse.dart';
-import 'package:flutter/cupertino.dart';
-import 'package:vid/us/vid_us_unit.dart';
 
 
 import '../primitives/trace.dart';
 import '../primitives/trace.dart';
 import 'calculator.dart';
 import 'calculator.dart';
@@ -26,12 +23,6 @@ class TracePerimeterCal extends Calculator<Trace, double> {
     //     threshold = ref.Threshold.Value;
     //     threshold = ref.Threshold.Value;
     // }
     // }
     double value = calcPerimeter(points, ref.feature!.isClosed, threshold);
     double value = calcPerimeter(points, ref.feature!.isClosed, threshold);
-    final outputItem =
-        createOutput(MeasureTypes.Perimeter, value, VidUsUnit.cm);
-    final description =
-        "${ref.description}: ${roundDouble(value)}${VidUsUnit.cm.name}";
-    outputItem.updateDescription(description: description);
-    output = outputItem;
     updateFloatValue(value);
     updateFloatValue(value);
   }
   }
 
 

+ 1 - 10
lib/process/calcuators/volume.dart

@@ -13,15 +13,13 @@ class VolumeThreeDistanceCal extends Calculator<LWHStraightLine, double> {
   void calculate() {
   void calculate() {
     if (ref.feature == null) return;
     if (ref.feature == null) return;
 
 
-    final outputMeta = ref.meta.outputs.first;
-    final outputItem = createOutput(outputMeta.name, 0, outputMeta.unit);
     final l = _pickChildOutput(ref.l);
     final l = _pickChildOutput(ref.l);
     final w = _pickChildOutput(ref.w);
     final w = _pickChildOutput(ref.w);
     final h = _pickChildOutput(ref.h);
     final h = _pickChildOutput(ref.h);
 
 
-    String description;
     final feature = ref.feature!;
     final feature = ref.feature!;
     final viewport = feature.hostVisualArea!.viewport!;
     final viewport = feature.hostVisualArea!.viewport!;
+
     if (l != null && w != null && h != null) {
     if (l != null && w != null && h != null) {
       final value = GeneralFormulas.volumeWithCoefficient(
       final value = GeneralFormulas.volumeWithCoefficient(
         l.value,
         l.value,
@@ -30,14 +28,7 @@ class VolumeThreeDistanceCal extends Calculator<LWHStraightLine, double> {
         GeneralFormulas.VolumeCofficient,
         GeneralFormulas.VolumeCofficient,
       );
       );
       updateFloatValue(value);
       updateFloatValue(value);
-      outputItem.value = value;
-      description = "${ref.description}  ${roundDouble(value)}cm³";
-    } else {
-      description = ref.description;
     }
     }
-
-    outputItem.updateDescription(description: description);
-    output = outputItem;
   }
   }
 
 
   OutputItem? _pickChildOutput(StraightLine item) {
   OutputItem? _pickChildOutput(StraightLine item) {

+ 3 - 0
lib/process/primitives/utils/auto_snap.dart

@@ -40,7 +40,10 @@ mixin AutoSnapMixin<T extends MeasureItemFeature> on MeasureItem<T> {
       isSmartMove = true;
       isSmartMove = true;
     }
     }
     if (length < autoSnapThreshold && isSmartMove) {
     if (length < autoSnapThreshold && isSmartMove) {
+      // feature!.innerPoints.removeLast();
+      feature!.innerPoints.last = feature!.innerPoints.first.clone();
       HapticFeedback.heavyImpact();
       HapticFeedback.heavyImpact();
+      doCalculate();
       doFeatureFinish();
       doFeatureFinish();
       isSmartMove = false;
       isSmartMove = false;
       return true;
       return true;

+ 1 - 1
lib/process/workspace/recorder.dart

@@ -71,7 +71,7 @@ class MeasureRecorder implements IMeasureRecorder {
         item.cancelOnce();
         item.cancelOnce();
       } else if (item.measuredFeatures.isNotEmpty) {
       } else if (item.measuredFeatures.isNotEmpty) {
         item.measuredFeatures.removeLast();
         item.measuredFeatures.removeLast();
-        item.calculator?.outputs.removeLast();
+        // item.calculator?.outputs.removeLast();
       }
       }
       return true;
       return true;
     }
     }

+ 2 - 2
lib/values/strings.dart

@@ -3,6 +3,6 @@
 class MeasureStrings {
 class MeasureStrings {
   static const PackageName = "fis_measure";
   static const PackageName = "fis_measure";
   static const LayoutConfigurationAsset =
   static const LayoutConfigurationAsset =
-      "packages/$PackageName/assets/layout.json";
-  // "assets/layout.json"; //TODO: melon - wait remove
+      // "packages/$PackageName/assets/layout.json";
+      "assets/layout.json"; //TODO: melon - wait remove
 }
 }