import 'package:flyinsono/lab/pages/lab_image/urm_data_processor/index.dart';
import 'package:flyinsono/lab/pages/lab_image/urm_data_processor/config/special_urm_config.dart';

/// URM 后处理坐标系参数
class ProcessPosParams {
  final double zoomRoiX;
  final double zoomRoiY;
  final double zoomRoiW;
  final double zoomRoiH;
  final int roiX;
  final int roiY;
  final int roiW;
  final int roiH;
  final int screenW;
  final int screenH;

  ProcessPosParams({
    this.zoomRoiX = 0,
    this.zoomRoiY = 0,
    this.zoomRoiW = 0,
    this.zoomRoiH = 0,
    this.roiX = 0,
    this.roiY = 0,
    this.roiW = 0,
    this.roiH = 0,
    this.screenW = 0,
    this.screenH = 0,
  });
}

/// URM 后处理图像参数
class PostProcessImageParams {
  double downsampleIndex = URMConfig.downsampleIndexConfig.defaultValue;
  double intPowerDen = URMConfig.intPowerDenConfig.defaultValue;
  double intPowerDir = URMConfig.intPowerDirConfig.defaultValue;
  double sigmaGauss = URMConfig.sigmaGaussConfig.defaultValue;
  double vessScale = URMConfig.vessScaleConfig.defaultValue;
  double velMaxScaler = URMConfig.velMaxScalerConfig.defaultValue;
  double velMinScaler = URMConfig.velMinScalerConfig.defaultValue;
  double iterations = URMConfig.iterationsConfig.defaultValue;
  // 视频参数
  double urmVideoParameter = URMConfig.urmVideoParameterConfig.defaultValue;
  double urmVideoType = URMConfig.urmVideoTypeConfig.defaultValue;
  double urmVideoIndex = URMConfig.urmVideoIndexConfig.defaultValue;

  PostProcessImageParams();

  void setParam(URMParamAdjust param) {
    print('URM 后处理图像参数变更: ${param.type} ${param.value}');
    switch (param.type) {
      case URMParamType.DownsampleIndex:
        if (param.value is double) {
          downsampleIndex = param.value;
        }
        break;
      case URMParamType.IntPowerDen:
        if (param.value is double) {
          intPowerDen = param.value;
        }
        break;
      case URMParamType.IntPowerDir:
        if (param.value is double) {
          intPowerDir = param.value;
        }
        break;
      case URMParamType.SigmaGauss:
        if (param.value is double) {
          sigmaGauss = param.value;
        }
        break;
      case URMParamType.VessScale:
        if (param.value is double) {
          vessScale = param.value;
        }
        break;
      case URMParamType.VelMaxScaler:
        if (param.value is double) {
          velMaxScaler = param.value;
        }
        break;
      case URMParamType.VelMinScaler:
        if (param.value is double) {
          velMinScaler = param.value;
        }
        break;
      case URMParamType.Iterations:
        if (param.value is double) {
          iterations = param.value;
        }
        break;
      case URMParamType.URMVideoParameter:
        if (param.value is double) {
          urmVideoParameter = param.value;
        }
        break;
      case URMParamType.URMVideoType:
        if (param.value is double) {
          urmVideoType = param.value;
        }
        break;
      case URMParamType.URMVideoIndex:
        if (param.value is double) {
          urmVideoIndex = param.value;
        }
        break;
      default:
        break;
    }
  }

  // 根据探头型号更新默认值参数
  void updateDefaultParamByProbeType(String probeType) {
    if (probeType == URMConfigConvexS18CM.probeType) {
      downsampleIndex = URMConfigConvexS18CM.downsampleIndexConfig.defaultValue;
      intPowerDen = URMConfigConvexS18CM.intPowerDenConfig.defaultValue;
      intPowerDir = URMConfigConvexS18CM.intPowerDirConfig.defaultValue;
      sigmaGauss = URMConfigConvexS18CM.sigmaGaussConfig.defaultValue;
      vessScale = URMConfigConvexS18CM.vessScaleConfig.defaultValue;
    }
  }
}
