|
@@ -11,6 +11,9 @@ import 'package:fis_measure/process/items/item.dart';
|
|
|
import 'package:fis_measure/utils/canvas.dart';
|
|
|
import 'package:fis_measure/view/gesture/cross_position_indicator.dart';
|
|
|
import 'package:fis_measure/view/gesture/positioned_cursor.dart';
|
|
|
+import 'package:fis_measure/view/gesture/positioned_touch_cursor.dart';
|
|
|
+import 'package:fis_ui/index.dart';
|
|
|
+import 'package:flutter/foundation.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
import 'package:vid/us/vid_us_mode.dart';
|
|
|
import '../items/item_feature.dart';
|
|
@@ -18,6 +21,8 @@ import '../items/item_feature.dart';
|
|
|
/// 只绘制一次直线,即会自动开始,不会自动结束
|
|
|
class SingleStraightLine extends MeasureItem<SingleStraightLineFeature> {
|
|
|
late final mouseState = Get.find<IMouseState>();
|
|
|
+ late final touchState = Get.find<ITouchPointState>();
|
|
|
+
|
|
|
SingleStraightLine(ItemMeta meta, IMeasureItem? parent) : super(meta, parent);
|
|
|
|
|
|
static SingleStraightLine createHeartRate(ItemMeta meta,
|
|
@@ -43,8 +48,7 @@ class SingleStraightLine extends MeasureItem<SingleStraightLineFeature> {
|
|
|
state = ItemStates.idle;
|
|
|
|
|
|
///重置十字样式
|
|
|
- mouseState.crossIndicatorStyleChanged
|
|
|
- .emit(this, CrossIndicatorStyle.nomal);
|
|
|
+ changeCrossIndicatorStyle(CrossIndicatorStyle.nomal);
|
|
|
}
|
|
|
} else if (state == ItemStates.idle) {
|
|
|
if (args.pointType == PointInfoType.mouseDown) {
|
|
@@ -53,19 +57,56 @@ class SingleStraightLine extends MeasureItem<SingleStraightLineFeature> {
|
|
|
state = ItemStates.running;
|
|
|
|
|
|
///设置十字样式
|
|
|
- mouseState.crossIndicatorStyleChanged
|
|
|
- .emit(this, CrossIndicatorStyle.vertical);
|
|
|
+ changeCrossIndicatorStyle(CrossIndicatorStyle.vertical);
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ bool isSetStyleOnMoveStart = false;
|
|
|
+
|
|
|
@override
|
|
|
bool onExecuteTouch(PointInfo args) {
|
|
|
- //TODO
|
|
|
+ if (state == ItemStates.finished || state == ItemStates.waiting) {
|
|
|
+ if (args.pointType == PointInfoType.touchDown) {
|
|
|
+ startMeasure(args);
|
|
|
+ state = ItemStates.running;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (state == ItemStates.running) {
|
|
|
+ feature?.startPoint = args;
|
|
|
+ feature?.endPoint = args;
|
|
|
+ doCalculate();
|
|
|
+ if (args.pointType == PointInfoType.touchUp) {
|
|
|
+ state = ItemStates.idle;
|
|
|
+ }
|
|
|
+ } else if (state == ItemStates.idle) {
|
|
|
+ feature?.endPoint = args;
|
|
|
+ doCalculate();
|
|
|
+ if (args.pointType == PointInfoType.touchUp) {
|
|
|
+ state = ItemStates.running;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置十字样式
|
|
|
+ if (args.pointType == PointInfoType.touchDown) {
|
|
|
+ isSetStyleOnMoveStart = false;
|
|
|
+ }
|
|
|
+ if (args.pointType == PointInfoType.touchMove && !isSetStyleOnMoveStart) {
|
|
|
+ changeCrossIndicatorStyle(CrossIndicatorStyle.vertical);
|
|
|
+ isSetStyleOnMoveStart = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ void changeCrossIndicatorStyle(CrossIndicatorStyle e) {
|
|
|
+ if (kIsMobile) {
|
|
|
+ touchState.crossIndicatorStyleChanged.emit(this, e);
|
|
|
+ } else {
|
|
|
+ mouseState.crossIndicatorStyleChanged.emit(this, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
void startMeasure(PointInfo args) {
|
|
|
final point = DPoint(0, 0);
|
|
|
if (args.hostVisualArea != null) {
|
|
@@ -80,8 +121,7 @@ class SingleStraightLine extends MeasureItem<SingleStraightLineFeature> {
|
|
|
if (mode == VidUsModeType.TissueTM || mode == VidUsModeType.Doppler) {
|
|
|
switch (meta.measureType) {
|
|
|
case MeasureTypes.HR:
|
|
|
- mouseState.crossIndicatorStyleChanged
|
|
|
- .emit(this, CrossIndicatorStyle.vertical);
|
|
|
+ changeCrossIndicatorStyle(CrossIndicatorStyle.vertical);
|
|
|
break;
|
|
|
default:
|
|
|
}
|
|
@@ -114,7 +154,8 @@ class SingleStraightLineFeature extends MeasureItemFeature {
|
|
|
|
|
|
@override
|
|
|
void paint(Canvas canvas, Size size) {
|
|
|
- if (startPoint == endPoint) return;
|
|
|
+ if (startPoint == endPoint && kIsWeb) return;
|
|
|
+
|
|
|
drawId(canvas, size, idText);
|
|
|
|
|
|
final startOffset = convert2ViewPoint(size, startPoint).toOffset();
|
|
@@ -143,7 +184,8 @@ class StraightLineHeartRateFeature extends SingleStraightLineFeature {
|
|
|
|
|
|
@override
|
|
|
void paint(Canvas canvas, Size size) {
|
|
|
- if (startPoint == endPoint) return;
|
|
|
+ if (startPoint == endPoint && kIsWeb) return;
|
|
|
+
|
|
|
drawId(canvas, size, idText);
|
|
|
final startOffset = convert2ViewPoint(size, startPoint).toOffset();
|
|
|
final endOffset = convert2ViewPoint(size, endPoint).toOffset();
|