point_info.dart 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import 'package:fis_measure/interfaces/date_types/point.dart';
  2. import 'package:fis_measure/interfaces/process/visuals/visual_area.dart';
  3. import 'package:flutter/painting.dart';
  4. /// 鼠标/手势 点坐标类型
  5. enum PointInfoType {
  6. mouseUp,
  7. mouseDown,
  8. mouseMove,
  9. touchUp,
  10. touchDown,
  11. touchMove,
  12. }
  13. /// 点信息
  14. class PointInfo extends DPoint {
  15. /// 点类型
  16. PointInfoType pointType;
  17. /// 点所在区域
  18. IVisualArea? hostVisualArea;
  19. /// [x] 横轴坐标
  20. ///
  21. /// [y] 纵轴坐标
  22. ///
  23. /// [pointType] 点类型
  24. PointInfo(double x, double y, this.pointType) : super(x, y);
  25. /// 根据鼠标位置创建点坐标信息
  26. ///
  27. /// [offset] 鼠标/触摸 点坐标位置
  28. ///
  29. /// [pointType] 点类型
  30. factory PointInfo.fromOffset(Offset offset, PointInfoType pointType) {
  31. return PointInfo(offset.dx, offset.dy, pointType);
  32. }
  33. /// 转换为Area内逻辑点
  34. DPoint toAreaLogicPoint() {
  35. if (hostVisualArea == null) return this;
  36. // TODO: 转换为Area内逻辑点
  37. return this;
  38. // return DPoint(x, y);
  39. }
  40. }