瀏覽代碼

update(measure): complete two location

gavin.chen 2 年之前
父節點
當前提交
52698ecef2
共有 2 個文件被更改,包括 10 次插入2 次删除
  1. 8 2
      lib/process/items/top_item.dart
  2. 2 0
      lib/process/primitives/combos/two_location.dart

+ 8 - 2
lib/process/items/top_item.dart

@@ -12,6 +12,7 @@ abstract class TopMeasureItem<T extends MeasureItemFeature>
   final List<IMeasureItem> _childItems = [];
   int _childIndex = 0;
 
+  bool get ifAutoStart => false;
   bool get ifAutoFinish => false;
 
   TopMeasureItem(ItemMeta meta) : super(meta) {
@@ -44,6 +45,12 @@ abstract class TopMeasureItem<T extends MeasureItemFeature>
 
   @override
   bool onExecuteMouse(PointInfo args) {
+    if (ifAutoStart) {
+      if (feature == null) {
+        feature = buildFeature();
+        listenChildrenUpdate();
+      }
+    }
     if (args.pointType == PointInfoType.mouseDown) {
       if (feature == null) {
         feature = buildFeature();
@@ -58,11 +65,10 @@ abstract class TopMeasureItem<T extends MeasureItemFeature>
     if (result) {
       doCalculate();
     }
-    //TODO:[Gavin] Sometimes Need Auto Finish
     if (ifAutoFinish) {
       if (args.pointType == PointInfoType.mouseDown) {
         if (childrenAllDone) {
-          print("此时应该结束测量");
+          application.switchItem(meta);
         }
       }
     }

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

@@ -11,6 +11,8 @@ import 'two_length.dart';
 class TwoLocation extends TwoLengthAbstract<TwoLocationFeature> {
   @override
   bool get ifAutoFinish => true;
+  @override
+  bool get ifAutoStart => true;
 
   late final Location x;
   late final Location y;