123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- import 'package:fis_measure/interfaces/date_types/point.dart';
- import 'package:fis_measure/interfaces/process/calculators/values.dart';
- import 'package:fis_measure/interfaces/process/items/terms.dart';
- import 'package:fis_measure/process/calcuators/formulas/general.dart';
- import 'package:fis_measure/process/items/item.dart';
- import 'package:fis_measure/process/items/item_feature.dart';
- import 'package:fis_measure/process/primitives/combos/two_length.dart';
- import 'package:vid/us/vid_us_unit.dart';
- import '../primitives/straightline.dart';
- import 'calculator.dart';
- class VerticalDistanceCal extends Calculator<StraightLine, double> {
- VerticalDistanceCal(StraightLine ref) : super(ref);
- @override
- void calculate() {
- if (ref.feature == null) return;
- final feature = ref.feature!;
- final viewport = feature.hostVisualArea!.viewport!;
- final p1 = feature.startPoint;
- final p2 = feature.endPoint;
- final pp1 = viewport.convert(p1);
- final pp2 = viewport.convert(p2);
- final value = (pp2.y - pp1.y).abs();
- updateFloatValue(value, useUnitY: true);
- }
- }
- class TimeSpanCal extends Calculator<StraightLine, double> {
- TimeSpanCal(StraightLine ref) : super(ref);
- @override
- void calculate() {
- if (ref.feature == null) return;
- final feature = ref.feature!;
- final viewport = feature.hostVisualArea!.viewport!;
- final p1 = feature.startPoint;
- final p2 = feature.endPoint;
- final pp1 = viewport.convert(p1);
- final pp2 = viewport.convert(p2);
- final value = (pp2.x - pp1.x).abs();
- updateFloatValue(value);
- }
- }
- class StenosisCal extends Calculator<TwoLengthAbstract, double> {
- StenosisCal(TwoLengthAbstract ref) : super(ref);
- @override
- void calculate() {
- if (ref.feature == null) return;
- final a1 = _pickChildValue(ref.child1);
- final a2 = _pickChildValue(ref.child2);
- final feature = ref.feature!;
- final viewport = feature.hostVisualArea!.viewport!;
- if (a1 != null && a2 != null) {
- final value = GeneralFormulas.countStenosis(
- a1,
- a2,
- );
- updateFloatValue(value);
- }
- }
- double? _pickChildValue(MeasureItem item) {
- if (item.calculator == null) return null;
- ValueBase? value;
- if (item.measuredFeatures.isNotEmpty) {
- value = item.measuredFeatures.first.value;
- } else if (item.feature != null) {
- value = item.feature!.value;
- }
- if (value != null) {
- return (value as FloatValue).value ?? 0;
- }
- return null;
- }
- }
- class SlopeCal extends Calculator<StraightLine, double> {
- SlopeCal(StraightLine ref) : super(ref);
- @override
- void calculate() {
- if (ref.feature == null) return;
- final feature = ref.feature!;
- final viewport = feature.hostVisualArea!.viewport!;
- final p1 = feature.startPoint;
- final p2 = feature.endPoint;
- final pp1 = viewport.convert(p1);
- final pp2 = viewport.convert(p2);
- final distance = (pp2.y - pp1.y).abs();
- final time = (pp2.x - pp1.x).abs();
- for (var output in ref.meta.outputs) {
- if (output.name == MeasureTerms.Slope) {
- var slope = GeneralFormulas.countSlope(pp1, pp2);
- feature.updateFloatValue(output, slope, output.unit);
- } else if (output.name == MeasureTerms.Timespan) {
- feature.updateFloatValue(output, time, output.unit);
- } else if (output.name == MeasureTerms.Distance) {
- feature.updateFloatValue(output, distance, output.unit);
- }
- }
- }
- }
- class SlopeDopplerCal extends Calculator<StraightLine, double> {
- SlopeDopplerCal(StraightLine ref) : super(ref);
- @override
- void calculate() {
- if (ref.feature == null) return;
- final feature = ref.feature!;
- final viewport = feature.hostVisualArea!.viewport!;
- final p1 = feature.startPoint;
- final p2 = feature.endPoint;
- final pp1 = viewport.convert(p1);
- final pp2 = viewport.convert(p2);
- final distance = (pp2.y - pp1.y).abs();
- final time = (pp2.x - pp1.x).abs();
- for (var output in ref.meta.outputs) {
- if (output.name == MeasureTerms.Slope) {
- var slope = GeneralFormulas.countSlope(pp2, pp1);
- feature.updateFloatValue(output, slope, output.unit);
- } else if (output.name == MeasureTerms.Timespan) {
- feature.updateFloatValue(output, time, output.unit);
- } else if (output.name == MeasureTerms.Distance) {
- feature.updateFloatValue(output, distance, output.unit);
- }
- }
- }
- }
- class DpDtCal extends Calculator<StraightLine, double> {
- DpDtCal(super.ref);
- @override
- void calculate() {
- if (ref.feature == null) return;
- final feature = ref.feature!;
- final p1 = feature.startPoint;
- final p2 = feature.endPoint;
- final pp1 = convertTimeMotionPoint(feature, p1);
- final pp2 = convertTimeMotionPoint(feature, p2);
- double dpDtRatio = GeneralFormulas.dpDtRatio(pp1, pp2);
- updateFloatValue(dpDtRatio, unit: VidUsUnit.mmHgs, useRound: true);
- }
- }
|