|
@@ -6,6 +6,7 @@ import 'package:fis_measure/interfaces/process/annotations/annotation.dart';
|
|
|
import 'package:fis_measure/interfaces/process/items/item.dart';
|
|
|
import 'package:fis_measure/interfaces/process/items/item_feature.dart';
|
|
|
import 'package:fis_measure/interfaces/process/items/item_metas.dart';
|
|
|
+import 'package:fis_measure/interfaces/process/items/types.dart';
|
|
|
import 'package:fis_measure/interfaces/process/visuals/visual_area.dart';
|
|
|
import 'package:fis_measure/interfaces/process/visuals/visual.dart';
|
|
|
import 'package:fis_measure/interfaces/process/viewports/viewport.dart';
|
|
@@ -47,6 +48,13 @@ class Application implements IApplication {
|
|
|
final Set<IAnnotationItem> _annotationItems = {};
|
|
|
late final _recorder = MeasureRecorder(this);
|
|
|
|
|
|
+ final emptyItem = ItemMeta(
|
|
|
+ "EmptyItem",
|
|
|
+ measureType: MeasureTypes.Empty,
|
|
|
+ description: "",
|
|
|
+ outputs: [],
|
|
|
+ );
|
|
|
+
|
|
|
Application(VidUsProbe probe) {
|
|
|
_probe = probe;
|
|
|
currentModeChanged = FEventHandler<IMode>();
|
|
@@ -331,6 +339,8 @@ class Application implements IApplication {
|
|
|
|
|
|
@override
|
|
|
void switchAnnotation([AnnotationType? type, String? text]) {
|
|
|
+ _handleBeforeExitMeasure();
|
|
|
+ switchItem(emptyItem);
|
|
|
_updateOperateType(MeasureOperateType.annotation);
|
|
|
final targetType = type ?? AnnotationType.input;
|
|
|
if (activeAnnotationItem != null &&
|
|
@@ -434,6 +444,22 @@ class Application implements IApplication {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 离开测量模式前处理
|
|
|
+ void _handleBeforeExitMeasure() {
|
|
|
+ if (activeMeasureItem == null) return;
|
|
|
+ final item = activeMeasureItem!;
|
|
|
+ if (item is TopMeasureItem && item.feature != null) {
|
|
|
+ bool isAllEmpty =
|
|
|
+ item.childItems.every((e) => e.measuredFeatures.isEmpty);
|
|
|
+ if (isAllEmpty) {
|
|
|
+ _recorder.undoOnce();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (item.feature != null) {
|
|
|
+ _recorder.undoOnce();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
void _clearFrameCache() {
|
|
|
_recorder.clear();
|
|
|
_annotationItems.clear();
|