|
@@ -1,3 +1,4 @@
|
|
|
+import 'package:fis_jsonrpc/rpc.dart';
|
|
|
import 'package:fis_measure/interfaces/enums/items.dart';
|
|
|
import 'package:fis_measure/interfaces/process/items/item.dart';
|
|
|
import 'package:fis_measure/interfaces/process/items/item_metas.dart';
|
|
@@ -15,6 +16,8 @@ import 'package:fis_measure/utils/prompt_box.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'dart:ui' as ui;
|
|
|
|
|
|
+import 'package:flutter/services.dart';
|
|
|
+
|
|
|
class URMTraceMeasure extends Trace {
|
|
|
URMTraceMeasure(super.meta, super.parent);
|
|
|
static bool needPerfusion = false;
|
|
@@ -115,11 +118,6 @@ class URMTraceMeasure extends Trace {
|
|
|
void handleMouseDownWhileWaiting(PointInfo args) {
|
|
|
if (needPerfusion) {
|
|
|
feature = TracePerfusionImageFeature(this);
|
|
|
- // if (args.hostVisualArea != null) {
|
|
|
- // feature!.hostVisualArea = args.hostVisualArea;
|
|
|
- // }
|
|
|
- // final point = args.toAreaLogicPoint();
|
|
|
- // feature!.adopt(point);
|
|
|
state = ItemStates.running;
|
|
|
} else {
|
|
|
super.handleMouseDownWhileWaiting(args);
|
|
@@ -137,18 +135,74 @@ class URMTraceMeasure extends Trace {
|
|
|
PromptBox.dismiss();
|
|
|
waitingResult = false;
|
|
|
}
|
|
|
+
|
|
|
+ /// 自动结束检测
|
|
|
+ @override
|
|
|
+ bool checkAutoSnap(PointInfo current, [bool autoFinishFeature = true]) {
|
|
|
+ if (feature == null || feature!.innerPoints.length < 3) {
|
|
|
+ isSmartMove = false;
|
|
|
+ return _syncState(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ // final viewport = feature!.hostVisualArea!.viewport!;
|
|
|
+
|
|
|
+ if (isAutoSnap == false) return false;
|
|
|
+ final pixelSize = application.displaySize;
|
|
|
+
|
|
|
+ final p1 = feature!.innerPoints.first.scale2Size(pixelSize);
|
|
|
+ final p2 = current.scale2Size(pixelSize);
|
|
|
+ final length = (p1 - p2).length;
|
|
|
+ if (length > snapThreshold * 2.0 && !isSmartMove) {
|
|
|
+ isSmartMove = true;
|
|
|
+ }
|
|
|
+ if (length < snapThreshold && isSmartMove) {
|
|
|
+ feature!.innerPoints.last = feature!.innerPoints.first.clone();
|
|
|
+
|
|
|
+ /// 此处的最后一个点,方便计算,但是绘制时要剔除
|
|
|
+ // feature!.innerPoints.removeLast();
|
|
|
+
|
|
|
+ HapticFeedback.heavyImpact();
|
|
|
+ if (autoFinishFeature) {
|
|
|
+ handleFinish();
|
|
|
+ }
|
|
|
+ isSmartMove = false;
|
|
|
+ return _syncState(true);
|
|
|
+ } else {
|
|
|
+ return _syncState(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ bool _syncState(bool isSnap) {
|
|
|
+ snapState = isSnap;
|
|
|
+ return snapState;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
class TracePerfusionImageFeature extends TraceFeature {
|
|
|
TracePerfusionImageFeature(AreaItemAbstract refItem) : super(refItem);
|
|
|
|
|
|
ui.Image? perfusionImg;
|
|
|
+ IntRect? perfusionPiexlRect;
|
|
|
+ Rect? perfusionScaleDRect;
|
|
|
@override
|
|
|
void paint(Canvas canvas, Size size) {
|
|
|
- super.paint(canvas, size);
|
|
|
if (perfusionImg != null) {
|
|
|
Paint paint = Paint();
|
|
|
- canvas.drawImage(perfusionImg!, Offset.zero, paint);
|
|
|
+
|
|
|
+ Rect src = Rect.fromLTWH(
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ perfusionImg!.width.toDouble(),
|
|
|
+ perfusionImg!.height.toDouble(),
|
|
|
+ );
|
|
|
+ Rect dst = Rect.fromLTWH(
|
|
|
+ perfusionScaleDRect!.left.toDouble() * size.width,
|
|
|
+ perfusionScaleDRect!.top.toDouble() * size.height,
|
|
|
+ perfusionScaleDRect!.width.toDouble() * size.width,
|
|
|
+ perfusionScaleDRect!.height.toDouble() * size.height,
|
|
|
+ );
|
|
|
+ canvas.drawImageRect(perfusionImg!, src, dst, paint);
|
|
|
}
|
|
|
+ super.paint(canvas, size);
|
|
|
}
|
|
|
}
|