import 'package:fis_measure/interfaces/date_types/point.dart';
import 'package:fis_measure/interfaces/process/visuals/visual_area.dart';
import 'package:flutter/painting.dart';

/// 鼠标/手势 点坐标类型
enum PointInfoType {
  mouseUp,
  mouseDown,
  mouseMove,
  touchUp,
  touchDown,
  touchMove,
}

/// 点信息
class PointInfo extends DPoint {
  /// 点类型
  PointInfoType pointType;

  /// 点所在区域
  IVisualArea? hostVisualArea;

  /// [x] 横轴坐标
  ///
  /// [y] 纵轴坐标
  ///
  /// [pointType] 点类型
  PointInfo(double x, double y, this.pointType) : super(x, y);

  /// 根据鼠标位置创建点坐标信息
  ///
  /// [offset] 鼠标/触摸 点坐标位置
  ///
  /// [pointType] 点类型
  factory PointInfo.fromOffset(Offset offset, PointInfoType pointType) {
    return PointInfo(offset.dx, offset.dy, pointType);
  }

  /// 转换为Area内逻辑点
  DPoint toAreaLogicPoint() {
    if (hostVisualArea == null) return this;
    // TODO: 转换为Area内逻辑点
    return DPoint(x, y);
  }
}
