Przeglądaj źródła

_handleBeforeSwitchItem

melon.yin 2 lat temu
rodzic
commit
85a059fe4a

+ 6 - 0
lib/interfaces/process/items/item.dart

@@ -37,6 +37,12 @@ abstract class IMeasureItem {
   /// 显示像素/图片像素 缩放比例
   double get scaleRatio;
 
+  /// 失活(切换到其他)后取消当前操作还是完成一次测量
+  bool get finishAfterUnactive;
+
+  /// 完成一次测量后是否还能编辑(是否切换到下一次测量)
+  bool get repeatableEditable;
+
   /// 处理输入
   bool execute(PointInfo args);
 

+ 8 - 8
lib/measure_page_test.dart

@@ -98,14 +98,14 @@ class _MeasureTestPageState extends State<MeasureTestPage> {
   static const C_LINEAR_TISSUE =
       // "http://cdn-bj.fis.plus/9F066341FA874E21B48CDE247C13D495.vid"; //B TVI TD
       // "http://cdn-bj.fis.plus/974BABA5113640639FD749E06DD7DA5B.vid"; //B CF CW
-      // "http://cdn-bj.fis.plus/0B344F48BA574ECD82B7FEDB8848421A.vid"; //单幅TM
-      // "http://cdn-bj.fis.plus/3379F38302884C2991D90FBDFB0DEA7E.dat"; //单幅TM(2)
-      // "http://cdn-bj.fis.plus/6A99AD2530864616B64355A8EA9AE3EC.vid";
-      // "http://cdn-bj.fis.plus/F26C6E5D57A7472A97E9EB543DF0D16C.vid"; // 单幅Convex
-      // "http://cdn-bj.fis.plus/6B6E069659D14E7299EB9F6EFCDE9C8C.vid"; //双幅单TissueConvex
-      // "http://cdn-bj.fis.plus/062643B82365437DB95F3811580AF3ED.vid"; //四幅单模式
-      // "http://cdn-bj.fis.plus/EA90D146049D416E8E466B7446E00001.vid"; //四幅Doppler
-      "http://cdn-bj.fis.plus/3rd_linearTvTissue2.vid"; //魔盒
+      "http://cdn-bj.fis.plus/0B344F48BA574ECD82B7FEDB8848421A.vid"; //单幅TM
+  // "http://cdn-bj.fis.plus/3379F38302884C2991D90FBDFB0DEA7E.dat"; //单幅TM(2)
+  // "http://cdn-bj.fis.plus/6A99AD2530864616B64355A8EA9AE3EC.vid";
+  // "http://cdn-bj.fis.plus/F26C6E5D57A7472A97E9EB543DF0D16C.vid"; // 单幅Convex
+  // "http://cdn-bj.fis.plus/6B6E069659D14E7299EB9F6EFCDE9C8C.vid"; //双幅单TissueConvex
+  // "http://cdn-bj.fis.plus/062643B82365437DB95F3811580AF3ED.vid"; //四幅单模式
+  // "http://cdn-bj.fis.plus/EA90D146049D416E8E466B7446E00001.vid"; //四幅Doppler
+  // "http://cdn-bj.fis.plus/3rd_linearTvTissue2.vid"; //魔盒
   // "http://cdn-bj.fis.plus/81FFF8E5E078473FA687FBE81C4869B1.vid"; // 魔盒TV
   // "http://cdn-bj.fis.plus/7B450708A2784B1490304C82787349BE.vid";// 胎儿Zoom
   static const C_CONVEX_TISSUE =

+ 8 - 1
lib/process/items/item.dart

@@ -24,6 +24,7 @@ abstract class MeasureItem<T extends MeasureItemFeature> extends IMeasureItem {
   MeasureItem(ItemMeta meta, [IMeasureItem? parent]) {
     _parent = parent;
     _meta = meta;
+    featureUpdated = FEventHandler<IMeasureItemFeature?>();
   }
 
   @override
@@ -80,7 +81,13 @@ abstract class MeasureItem<T extends MeasureItemFeature> extends IMeasureItem {
   double get scaleRatio => application.displayScaleRatio;
 
   @override
-  late final featureUpdated = FEventHandler<IMeasureItemFeature?>();
+  bool get finishAfterUnactive => true;
+
+  @override
+  bool get repeatableEditable => false;
+
+  @override
+  late final FEventHandler<IMeasureItemFeature?> featureUpdated;
 
   @override
   bool execute(PointInfo args) {

+ 6 - 0
lib/process/items/top_item.dart

@@ -30,6 +30,12 @@ abstract class TopMeasureItem<T extends MeasureItemFeature>
   bool get childrenAllDone =>
       _childItems.every((e) => e.measuredFeatures.isNotEmpty);
 
+  @override
+  bool get finishAfterUnactive => false;
+
+  @override
+  bool get repeatableEditable => true;
+
   @override
   late final FEventHandler<int> workingChildChanged;
 

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

@@ -24,6 +24,9 @@ import '../physical_coordinates/convex_tissue.dart';
 class Location extends MeasureItem<LocationFeature> {
   Location(ItemMeta meta, IMeasureItem? parent) : super(meta, parent);
 
+  @override
+  bool get finishAfterUnactive => false;
+
   @override
   bool onExecuteMouse(PointInfo args) {
     if (state == ItemStates.finished || state == ItemStates.waiting) {

+ 14 - 0
lib/process/workspace/application.dart

@@ -307,6 +307,7 @@ class Application implements IApplication {
   @override
   void switchItem(ItemMeta meta) {
     _updateOperateType(MeasureOperateType.measure);
+    _handleBeforeSwitchItem();
     activeMeasureItem = MeasureItemFactory.createItem(meta);
   }
 
@@ -384,6 +385,19 @@ class Application implements IApplication {
     return VisualsLoader(frameData!.visuals).load();
   }
 
+  void _handleBeforeSwitchItem() {
+    if (activeMeasureItem == null) return;
+
+    final item = activeMeasureItem!;
+    if (item.feature != null) {
+      if (item is ITopMeasureItem || item.finishAfterUnactive) {
+        item.finishOnce();
+      } else {
+        _recorder.undoOnce();
+      }
+    }
+  }
+
   void _clearFrameCache() {
     _recorder.clear();
     _annotationItems.clear();