three_distance.dart 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import 'package:fis_measure/interfaces/process/calculators/output.dart';
  2. import 'package:fis_measure/interfaces/process/calculators/values.dart';
  3. import 'package:fis_measure/process/calcuators/formulas/general.dart';
  4. import 'package:fis_measure/process/items/item.dart';
  5. import 'package:fis_measure/process/primitives/combos/lwh_straightline.dart';
  6. import 'package:fis_measure/process/primitives/ellipse.dart';
  7. import 'package:fis_measure/process/primitives/straightline.dart';
  8. import 'package:vid/us/vid_us_unit.dart';
  9. import 'calculator.dart';
  10. import 'formulas/cardiac.dart';
  11. import 'formulas/obstetrics.dart';
  12. class VolumeThreeDistanceCal extends Calculator<LWHStraightLine, double> {
  13. VolumeThreeDistanceCal(LWHStraightLine ref) : super(ref);
  14. @override
  15. void calculate() {
  16. if (ref.feature == null) return;
  17. final l = pickChildFloatValue(ref.l);
  18. final w = pickChildFloatValue(ref.w);
  19. final h = pickChildFloatValue(ref.h);
  20. final feature = ref.feature!;
  21. final viewport = feature.hostVisualArea!.viewport!;
  22. if (l != null && w != null && h != null) {
  23. final value = GeneralFormulas.volumeWithCoefficient(
  24. l,
  25. w,
  26. h,
  27. GeneralFormulas.VolumeCofficient,
  28. );
  29. updateFloatValue(value);
  30. }
  31. }
  32. }
  33. class ThreeDistMeanCalculator extends Calculator<LWHStraightLine, double> {
  34. ThreeDistMeanCalculator(LWHStraightLine ref) : super(ref);
  35. @override
  36. void calculate() {
  37. if (ref.feature == null) return;
  38. final l = pickChildFloatValue(ref.l);
  39. final w = pickChildFloatValue(ref.w);
  40. final h = pickChildFloatValue(ref.h);
  41. if (l != null && w != null && h != null) {
  42. final value = ObstetricsFormulas.gsMean(l, w, h);
  43. updateFloatValue(value);
  44. }
  45. }
  46. }
  47. class ThreeDistMaxCalculator extends Calculator<LWHStraightLine, double> {
  48. ThreeDistMaxCalculator(LWHStraightLine ref) : super(ref);
  49. @override
  50. void calculate() {
  51. if (ref.feature == null) return;
  52. final l = findChildFeature(ref.l);
  53. final w = findChildFeature(ref.w);
  54. final h = findChildFeature(ref.h);
  55. if (l == null && w == null && h == null) return;
  56. double lineL = 0;
  57. double lineW = 0;
  58. double lineH = 0;
  59. if (l != null) lineL = l.value?.pickFloat() ?? 0;
  60. if (w != null) lineW = w.value?.pickFloat() ?? 0;
  61. if (h != null) lineH = h.value?.pickFloat() ?? 0;
  62. double gs = ObstetricsFormulas.gsMax(lineL, lineW, lineH);
  63. updateFloatValue(gs, unit: VidUsUnit.cm, useRound: true);
  64. }
  65. }
  66. class PercentMAMCalculator extends Calculator<LWHStraightLine, double> {
  67. PercentMAMCalculator(LWHStraightLine ref) : super(ref);
  68. @override
  69. void calculate() {
  70. if (ref.feature == null) return;
  71. final feature = ref.feature!;
  72. final l = findChildFeature(ref.l);
  73. final w = findChildFeature(ref.w);
  74. final h = findChildFeature(ref.h);
  75. if (l == null && w == null && h == null) return;
  76. updateStringValue("");
  77. double? mapse;
  78. double? lvidd;
  79. double? lvids;
  80. if (l != null) mapse = l.value?.pickFloat() ?? 0;
  81. if (w != null) lvidd = w.value?.pickFloat() ?? 0;
  82. if (h != null) lvids = h.value?.pickFloat() ?? 0;
  83. if (mapse != null && lvidd != null && lvids != null) {
  84. double mam = CardiacFormulas.mamPercent(mapse, lvidd, lvids);
  85. // updateFloatValue(mam, unit: VidUsUnit.percent);
  86. final outputMeta =
  87. ref.meta.outputs.first.copyWith(unit: VidUsUnit.percent);
  88. feature.updateFloatValue(outputMeta, mam, VidUsUnit.percent);
  89. }
  90. }
  91. }