|
@@ -9,10 +9,13 @@ import 'package:fis_measure/process/calcuators/trace.dart';
|
|
|
import 'package:fis_measure/process/items/item.dart';
|
|
|
import 'package:fis_measure/process/items/item_feature.dart';
|
|
|
import 'package:fis_measure/utils/canvas.dart';
|
|
|
+import 'package:fis_measure/view/gesture/positioned_touch_cursor.dart';
|
|
|
+import 'package:get/get.dart';
|
|
|
|
|
|
/// 手势轨迹图形
|
|
|
class MultiTrace extends TraceItemAbstract {
|
|
|
MultiTrace(ItemMeta meta, IMeasureItem? parent) : super(meta, parent);
|
|
|
+ late final touchState = Get.find<ITouchPointState>();
|
|
|
|
|
|
@override
|
|
|
bool onExecuteMouse(PointInfo args) {
|
|
@@ -55,7 +58,21 @@ class MultiTrace extends TraceItemAbstract {
|
|
|
state = ItemStates.running;
|
|
|
}
|
|
|
|
|
|
+ void handleTouchDownWhileWaiting(PointInfo args) {
|
|
|
+ // TODO: 判断是否当前area
|
|
|
+ // 转换为Area逻辑位置
|
|
|
+ feature = MultiTraceFeature(this);
|
|
|
+ if (args.hostVisualArea != null) {
|
|
|
+ feature!.hostVisualArea = args.hostVisualArea;
|
|
|
+ }
|
|
|
+ final point = args.toAreaLogicPoint();
|
|
|
+ feature!.adopt(point);
|
|
|
+ // state = ItemStates.running;
|
|
|
+ }
|
|
|
+
|
|
|
PointInfo? startPoint;
|
|
|
+ DPoint touchStartPosition = DPoint(0, 0); // 相对位移起始触摸点
|
|
|
+ bool isFirstPointMove = false;
|
|
|
@override
|
|
|
bool onExecuteTouch(PointInfo args) {
|
|
|
if (state == ItemStates.finished) {
|
|
@@ -65,24 +82,46 @@ class MultiTrace extends TraceItemAbstract {
|
|
|
}
|
|
|
|
|
|
if (state == ItemStates.waiting) {
|
|
|
+ if (isFirstPointMove) {
|
|
|
+ args.addOffset(0, -0.2);
|
|
|
+ }
|
|
|
switch (args.pointType) {
|
|
|
case PointInfoType.touchDown:
|
|
|
+ isFirstPointMove = false;
|
|
|
startPoint = args; // 设置线段起点
|
|
|
+ handleTouchDownWhileWaiting(startPoint!); // 通过设置的起点开始一个绘制事件
|
|
|
break;
|
|
|
case PointInfoType.touchUp:
|
|
|
+ startPoint = args; // 设置线段起点
|
|
|
+ state = ItemStates.running;
|
|
|
+ touchState.touchOffset = Offset.zero;
|
|
|
break; // 按下立即抬起无事发生
|
|
|
case PointInfoType.touchMove:
|
|
|
- handleMouseDownWhileWaiting(startPoint!); // 通过设置的起点开始一个绘制事件
|
|
|
+ isFirstPointMove = true;
|
|
|
+ final pixelSize = application.displaySize;
|
|
|
+ touchState.touchOffset =
|
|
|
+ DPoint(0, -0.2).scale2Size(pixelSize).toOffset();
|
|
|
+ feature?.innerPoints.first = args;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
} else if (state == ItemStates.running) {
|
|
|
+ if (args.pointType == PointInfoType.touchDown) {
|
|
|
+ touchStartPosition = args;
|
|
|
+ final pixelSize = application.displaySize;
|
|
|
+ touchState.touchOffset = startPoint!.scale2Size(pixelSize).toOffset() -
|
|
|
+ args.scale2Size(pixelSize).toOffset();
|
|
|
+ }
|
|
|
if (args.pointType == PointInfoType.touchUp) {
|
|
|
+ touchState.touchOffset = Offset.zero;
|
|
|
doFeatureFinish();
|
|
|
}
|
|
|
if (args.pointType == PointInfoType.touchMove) {
|
|
|
- feature?.adopt(args);
|
|
|
+ PointInfo newPoint = PointInfo.fromOffset(
|
|
|
+ startPoint!.clone().addVector(args - touchStartPosition).toOffset(),
|
|
|
+ startPoint!.pointType);
|
|
|
+ feature?.adopt(newPoint);
|
|
|
doCalculate();
|
|
|
}
|
|
|
}
|
|
@@ -120,6 +159,11 @@ class MultiTraceFeature extends TraceItemFeatureAbstract {
|
|
|
hostVisualArea!.displayRegion.bottom * size.height;
|
|
|
|
|
|
if (innerPoints.isEmpty) return;
|
|
|
+ if (innerPoints.length == 1) {
|
|
|
+ drawVertex(canvas, convert2ViewPoint(size, innerPoints[0]).toOffset());
|
|
|
+ drawId(canvas, size);
|
|
|
+ return;
|
|
|
+ }
|
|
|
double maxDistance = 0;
|
|
|
drawId(canvas, size);
|
|
|
|