urm_location.dart 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import 'package:fis_measure/interfaces/enums/items.dart';
  2. import 'package:fis_measure/interfaces/process/items/item.dart';
  3. import 'package:fis_measure/interfaces/process/items/item_metas.dart';
  4. import 'package:fis_measure/interfaces/process/workspace/point_info.dart';
  5. import 'package:fis_measure/process/primitives/location.dart';
  6. import 'package:fis_measure/utils/prompt_box.dart';
  7. class URMLoaction extends Location {
  8. URMLoaction(ItemMeta meta, IMeasureItem? parent) : super(meta, parent);
  9. static URMLoaction createURMLocation(
  10. ItemMeta meta, [
  11. IMeasureItem? parent,
  12. ]) {
  13. URMLoaction location = URMLoaction(meta, parent);
  14. // location.calculator = URMLocationCal(location);
  15. return location;
  16. }
  17. @override
  18. bool onExecuteMouse(PointInfo args) {
  19. if (waitingResult) return false;
  20. if (state == ItemStates.finished || state == ItemStates.waiting) {
  21. if (args.pointType == PointInfoType.mouseMove) {
  22. handleMouseMoveWhileFinish(args);
  23. }
  24. }
  25. if (state == ItemStates.running) {
  26. if (args.pointType == PointInfoType.mouseUp) return false;
  27. feature?.point = args;
  28. if (args.pointType == PointInfoType.mouseDown) {
  29. handleFinish();
  30. }
  31. }
  32. return true;
  33. }
  34. bool waitingResult = false;
  35. void handleFinish() async {
  36. feature!.isActive = false;
  37. waitingResult = true;
  38. await doCalculateAsync();
  39. doFeatureFinish();
  40. PromptBox.dismiss();
  41. waitingResult = false;
  42. }
  43. @override
  44. bool onExecuteTouch(PointInfo args) {
  45. if (state == ItemStates.finished || state == ItemStates.waiting) {
  46. if (args.pointType == PointInfoType.touchDown) {
  47. handleMouseMoveWhileFinish(args);
  48. }
  49. }
  50. if (state == ItemStates.running) {
  51. if (args.pointType == PointInfoType.touchDown) {
  52. feature?.point = args;
  53. doCalculate();
  54. doFeatureFinish();
  55. }
  56. }
  57. return true;
  58. }
  59. }