Browse Source

跨帧后无法测量问题修复

Melon 11 months ago
parent
commit
ffe38bf732

+ 2 - 2
lib/interfaces/process/items/item.dart

@@ -76,8 +76,8 @@ abstract class ITopMeasureItem implements IMeasureItem {
   /// 工作中子项
   IMeasureItem get workingChild;
 
-  /// 是否多帧模式(测量中存在跨帧行为)
-  bool get isMultiFrameMode;
+  /// 是否跨帧测量模式
+  bool get isCrossFrameMode;
 
   /// 工作子项变更事件
   late final FEventHandler<int> workingChildChanged;

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

@@ -38,7 +38,7 @@ abstract class TopMeasureItem<T extends MeasureItemFeature>
   bool get repeatableEditable => true;
 
   @override
-  bool get isMultiFrameMode => false;
+  bool get isCrossFrameMode => false;
 
   @override
   late final FEventHandler<int> workingChildChanged;

+ 34 - 25
lib/process/workspace/application.dart

@@ -35,6 +35,7 @@ class Application implements IApplication {
 
   late VidUsProbe _probe;
   VidUsImage? _frame;
+  VidUsImage? _subFrame;
   List<IVisual>? _visuals;
   IMeasureItem? _activeMeasureItem;
   IAnnotationItem? _activeAnnotationItem;
@@ -106,7 +107,7 @@ class Application implements IApplication {
   IVisualArea get currentVisualArea => currentVisual.activeArea!;
 
   @override
-  VidUsImage? get frameData => _frame;
+  VidUsImage? get frameData => _subFrame ?? _frame;
 
   @override
   List<IVisual> get visuals => _visuals ?? [];
@@ -204,6 +205,12 @@ class Application implements IApplication {
         _activeMeasureItem!.featureUpdated
             .addListener(_onActiveMeasureItemFeatureUpdated);
       }
+      if (_subFrame != null) {
+        // 清除附帧并恢复原始帧的Visual状态
+        _subFrame = null;
+        loadVisuals();
+      }
+
       // 通知更新事件
       activeMeasureItemChanged.emit(this, value);
       _updateRender();
@@ -281,13 +288,15 @@ class Application implements IApplication {
     }
 
     if (activeMeasureItem != null && activeMeasureItem! is ITopMeasureItem) {
-      if ((activeMeasureItem as ITopMeasureItem).isMultiFrameMode) {
-        _frame = VidUsImage(
-          _frame!.index,
-          frame.width,
-          frame.height,
-          frame.imageData,
-        );
+      if ((activeMeasureItem as ITopMeasureItem).isCrossFrameMode) {
+        // _frame = VidUsImage(
+        //   _frame!.index,
+        //   frame.width,
+        //   frame.height,
+        //   frame.imageData,
+        // );
+        // TODO: 暂不支持直接改index
+        _subFrame = frame;
         // 仅更新frame数据
         loadVisuals();
         return;
@@ -454,6 +463,23 @@ class Application implements IApplication {
     return VisualsLoader(frameData!.visuals).load();
   }
 
+  @protected
+  void loadVisuals() {
+    _clearVisuals();
+    _visuals = convertVisuals();
+    // 默认第一个区域为活动域
+    switchVisual(0);
+    visualsLoaded.emit(this, null);
+  }
+
+  @override
+  void loadCarotidVisuals(VidUsImage carotidVid) {
+    _clearVisuals();
+    _visuals = VisualsLoader(carotidVid.visuals).load();
+    switchVisual(0);
+    visualsLoaded.emit(this, null);
+  }
+
   void _handleBeforeSwitchItem() {
     if (activeMeasureItem == null) return;
     final item = activeMeasureItem!;
@@ -534,23 +560,6 @@ class Application implements IApplication {
     _updateRender();
   }
 
-  @protected
-  void loadVisuals() {
-    _clearVisuals();
-    _visuals = convertVisuals();
-    // 默认第一个区域为活动域
-    switchVisual(0);
-    visualsLoaded.emit(this, null);
-  }
-
-  @override
-  void loadCarotidVisuals(VidUsImage carotidVid) {
-    _clearVisuals();
-    _visuals = VisualsLoader(carotidVid.visuals).load();
-    switchVisual(0);
-    visualsLoaded.emit(this, null);
-  }
-
   void _clearVisuals() {
     _visuals = [];
   }

+ 3 - 0
lib/view/player/cross_frame/sub_frame.dart

@@ -0,0 +1,3 @@
+class CrossSubFrameHost {
+  //
+}