|
@@ -1,7 +1,14 @@
|
|
|
+import 'package:fis_measure/interfaces/date_types/point.dart';
|
|
|
+import 'package:fis_measure/interfaces/date_types/rect.dart';
|
|
|
+import 'package:fis_measure/interfaces/date_types/rect_region.dart';
|
|
|
import 'package:fis_measure/interfaces/process/workspace/application.dart';
|
|
|
import 'package:fis_measure/interfaces/process/workspace/point_info.dart';
|
|
|
+import 'package:fis_measure/view/gesture/cross_position_indicator.dart';
|
|
|
+import 'package:fis_measure/view/gesture/mouse_gesture.dart';
|
|
|
+import 'package:fis_measure/view/gesture/positioned_touch_cursor.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
+import 'package:vid/us/vid_us_visual_area_type.dart';
|
|
|
|
|
|
class MeasureTouchGesturePanel extends StatefulWidget {
|
|
|
const MeasureTouchGesturePanel({Key? key}) : super(key: key);
|
|
@@ -13,8 +20,16 @@ class MeasureTouchGesturePanel extends StatefulWidget {
|
|
|
class _MeasureTouchGesturePanelState extends State<MeasureTouchGesturePanel> {
|
|
|
late final application = Get.find<IApplication>();
|
|
|
|
|
|
+ final touchState = Get.find<ITouchPointState>();
|
|
|
+
|
|
|
+ CursorDisplayType displayType = CursorDisplayType.none;
|
|
|
+ RectRegion tissueTMPixelRegion = RectRegion();
|
|
|
+ bool ifContainerTissueTM = false;
|
|
|
+ Offset _lastPosition = Offset.zero;
|
|
|
+
|
|
|
@override
|
|
|
void initState() {
|
|
|
+ _findMultiRegions();
|
|
|
super.initState();
|
|
|
}
|
|
|
|
|
@@ -25,31 +40,115 @@ class _MeasureTouchGesturePanelState extends State<MeasureTouchGesturePanel> {
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
- return GestureDetector(onTapDown: (details) {
|
|
|
- application.createPointInfo(
|
|
|
- details.localPosition,
|
|
|
- PointInfoType.touchDown,
|
|
|
- );
|
|
|
- }, onPanDown: (details) {
|
|
|
- application.createPointInfo(
|
|
|
- details.localPosition,
|
|
|
- PointInfoType.touchDown,
|
|
|
- );
|
|
|
- }, onPanUpdate: (details) {
|
|
|
- application.createPointInfo(
|
|
|
- details.localPosition,
|
|
|
- PointInfoType.touchMove,
|
|
|
- );
|
|
|
- }, onTapUp: (details) {
|
|
|
- application.createPointInfo(
|
|
|
- details.localPosition,
|
|
|
- PointInfoType.touchUp,
|
|
|
- );
|
|
|
- }, onPanEnd: (details) {
|
|
|
- application.createPointInfo(
|
|
|
- Offset.zero,
|
|
|
- PointInfoType.touchUp,
|
|
|
- );
|
|
|
- });
|
|
|
+ return GestureDetector(
|
|
|
+ behavior: HitTestBehavior.opaque,
|
|
|
+ onTapDown: (details) {
|
|
|
+ touchState.mousePosition = details.localPosition;
|
|
|
+ _handleAreaChange(details.localPosition);
|
|
|
+ application.createPointInfo(
|
|
|
+ details.localPosition,
|
|
|
+ PointInfoType.touchDown,
|
|
|
+ );
|
|
|
+ },
|
|
|
+ onPanDown: (details) {
|
|
|
+ touchState.mousePosition = details.localPosition;
|
|
|
+ _handleAreaChange(details.localPosition);
|
|
|
+ application.createPointInfo(
|
|
|
+ details.localPosition,
|
|
|
+ PointInfoType.touchDown,
|
|
|
+ );
|
|
|
+ },
|
|
|
+ onPanUpdate: (details) {
|
|
|
+ touchState.mousePosition = details.localPosition;
|
|
|
+ _handleAreaChange(details.localPosition);
|
|
|
+ _lastPosition = details.localPosition;
|
|
|
+ application.createPointInfo(
|
|
|
+ details.localPosition,
|
|
|
+ PointInfoType.touchMove,
|
|
|
+ );
|
|
|
+ },
|
|
|
+ onTapUp: (details) {
|
|
|
+ touchState.mousePosition = details.localPosition;
|
|
|
+ setState(() {
|
|
|
+ displayType = CursorDisplayType.normal;
|
|
|
+ });
|
|
|
+ application.createPointInfo(
|
|
|
+ details.localPosition,
|
|
|
+ PointInfoType.touchUp,
|
|
|
+ );
|
|
|
+ },
|
|
|
+ onPanEnd: (details) {
|
|
|
+ application.createPointInfo(
|
|
|
+ _lastPosition,
|
|
|
+ PointInfoType.touchUp,
|
|
|
+ );
|
|
|
+ setState(() {
|
|
|
+ displayType = CursorDisplayType.normal;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ child: _buildCursor(),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ Widget _buildCursor() {
|
|
|
+ switch (displayType) {
|
|
|
+ case CursorDisplayType.none:
|
|
|
+ return Container();
|
|
|
+ case CursorDisplayType.normal:
|
|
|
+ return Container();
|
|
|
+ case CursorDisplayType.cross:
|
|
|
+ return Stack(
|
|
|
+ children: [
|
|
|
+ MobileCrossIndicator(
|
|
|
+ areaRegion: Rect.fromLTRB(
|
|
|
+ tissueTMPixelRegion.left,
|
|
|
+ tissueTMPixelRegion.top,
|
|
|
+ tissueTMPixelRegion.right,
|
|
|
+ tissueTMPixelRegion.bottom),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void _handleAreaChange(Offset pointerOffset) {
|
|
|
+ if (ifContainerTissueTM) {
|
|
|
+ if (tissueTMPixelRegion
|
|
|
+ .containsPoint(DPoint.parseOffset(pointerOffset))) {
|
|
|
+ if (displayType != CursorDisplayType.cross) {
|
|
|
+ setState(() {
|
|
|
+ displayType = CursorDisplayType.cross;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (displayType != CursorDisplayType.normal) {
|
|
|
+ setState(() {
|
|
|
+ displayType = CursorDisplayType.normal;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void _findMultiRegions() {
|
|
|
+ final displaySize = application.displaySize;
|
|
|
+ for (var visual in application.visuals) {
|
|
|
+ for (var area in visual.visualAreas) {
|
|
|
+ if (area.visualAreaType == VidUsVisualAreaType.TissueTimeMotion ||
|
|
|
+ area.visualAreaType == VidUsVisualAreaType.Doppler) {
|
|
|
+ ifContainerTissueTM = true;
|
|
|
+
|
|
|
+ ///TODO 由于布局问题 Left 定位给不准,这里放宽到边界
|
|
|
+ tissueTMPixelRegion = RectRegion.rect(DRect(
|
|
|
+ // area.displayRegion.left * displaySize.width,
|
|
|
+ 0,
|
|
|
+ area.displayRegion.top * displaySize.height,
|
|
|
+ // area.displayRegion.width * displaySize.width,
|
|
|
+ displaySize.width,
|
|
|
+ area.displayRegion.height * displaySize.height,
|
|
|
+ ));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|