Browse Source

fix(measure): 完善切换测量项时结束事件逻辑 #0008961

gavin.chen 2 years ago
parent
commit
5370b06869

+ 5 - 0
lib/interfaces/process/workspace/application.dart

@@ -135,6 +135,11 @@ abstract class IApplication {
   /// [meta] 测量项信息
   void switchItem(ItemMeta meta);
 
+  /// 自动开始下一次测量,用于组合测量的自动结束事件
+  ///
+  /// [meta] 测量项信息
+  void autoStartAgain(ItemMeta meta);
+
   /// 切换注释
   ///
   /// [type] 注释类型

+ 1 - 1
lib/process/items/top_item.dart

@@ -74,7 +74,7 @@ abstract class TopMeasureItem<T extends MeasureItemFeature>
     if (ifAutoFinish) {
       if (args.pointType == PointInfoType.mouseDown) {
         if (childrenAllDone) {
-          application.switchItem(meta);
+          application.autoStartAgain(meta);
         }
       }
     }

+ 2 - 0
lib/process/primitives/combos/three_ray.dart

@@ -21,6 +21,8 @@ class ThreeRay extends ThreeRayAbstract<ThreeRayFeature> {
   bool get ifAutoFinish => true;
   @override
   bool get ifAutoStart => true;
+  @override
+  bool get finishAfterUnactive => false;
 
   late final Ray x;
   late final Ray y;

+ 2 - 0
lib/process/primitives/combos/two_ray.dart

@@ -20,6 +20,8 @@ class TwoRay extends TwoRayAbstract<TwoRayFeature> {
   bool get ifAutoFinish => true;
   @override
   bool get ifAutoStart => true;
+  @override
+  bool get finishAfterUnactive => false;
 
   late final Ray x;
   late final Ray y;

+ 11 - 2
lib/process/workspace/application.dart

@@ -311,6 +311,16 @@ class Application implements IApplication {
     activeMeasureItem = MeasureItemFactory.createItem(meta);
   }
 
+  @override
+  void autoStartAgain(ItemMeta meta) {
+    if (activeMeasureItem == null) return;
+    final item = activeMeasureItem!;
+    if (item.feature != null) {
+      item.finishOnce();
+    }
+    activeMeasureItem = MeasureItemFactory.createItem(meta);
+  }
+
   @override
   void switchAnnotation([AnnotationType? type, String? text]) {
     _updateOperateType(MeasureOperateType.annotation);
@@ -387,10 +397,9 @@ class Application implements IApplication {
 
   void _handleBeforeSwitchItem() {
     if (activeMeasureItem == null) return;
-
     final item = activeMeasureItem!;
     if (item.feature != null) {
-      if (item is ITopMeasureItem || item.finishAfterUnactive) {
+      if (item.finishAfterUnactive) {
         item.finishOnce();
       } else {
         _recorder.undoOnce();