// Created with MonoDevelop
//
//    Copyright (C) 2024 Hiperscan GmbH Dresden, Germany
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;

using Hiperscan.Spectroscopy;
using Hiperscan.Spectroscopy.Processing.Transformations;
using Hiperscan.Unix;

namespace Hiperscan.Spectroscopy.Processing
{
    public partial class SpectrumProcessor
    {
        public ExternalWhiteReferenceType ExternalWhiteReferenceType { get; set; } = ExternalWhiteReferenceType.Zenith;

        public bool NoCreatorUpdate { get; set; } = false;

        public TransformationTypes TransformationType { get; set; } = TransformationTypes.None;

        public bool WithWavelengthCorrection { get; set; } = true;

        public WlcMaxIterationReachedBehavior MaxIterationReachedBehavior { get; set; } 

        public InstrumentReferenceSystem InstrumentReferenceSystem
        {
            get;
            protected set;
        }

        public override ExternalBackgroundType ExternalBackgroundType
        {
            get
            {
                if (this.external_background_type == ExternalBackgroundType.Unknown)
                    this.UpdateProcessingBackground();

                return this.external_background_type;
            }
        }

        public CorrectionMask CorrectionMask
        {
            get
            {
                return this.correction_mask;
            }
            set
            {
                this.correction_mask = value;
                this.ResetAll();
            }
        }

        public WhiteReferenceConversionMode WhiteReferenceConversionMode
        {
            get { return this.white_reference_conversion_mode; }
            set
            {
                this.white_reference_conversion_mode = value;
                this.ResetExternalReferences();
            }
        }

        public bool HasAdcCorrection
        {
            get
            {
                return (this.CorrectionMask & CorrectionMask.Adc) != CorrectionMask.None;
            }
        }

        public Spectrum ForcedMasterOxidReference
        {
            get
            {
                return this.forced_master_oxid_reference;
            }
            set
            {
                this.forced_master_oxid_reference = value?.Clone();
            }
        }

        public ReferenceWheelVersion ReferenceWheelVersion
        {
            get
            {
                return this.reference_wheel_version;
            }
            set
            {
                this.reference_wheel_version = value;
                this.forced_master_oxid_reference = null;
            }
        }

        public bool HasForcedMasterOxidReference
        {
            get
            {
                return this.forced_master_oxid_reference != null;
            }
        }

        public LimitBandwidthMode RawSpectrumLimitBandwidthMode
        {
            get
            {
                return this.raw_spectrum_limit_bandwidth_mode;
            }
            set
            {
                this.raw_spectrum_limit_bandwidth_mode = value;
                this.ResetAll();
            }
        }

        public LimitBandwidthMode ProcessedSpectrumLimitBandwidthMode
        {
            get
            {
                return this.processed_spectrum_limit_bandwith_mode;
            }
            set
            {
                this.processed_spectrum_limit_bandwith_mode = value;
            }
        }

        public bool DontReapplyWavelengthCorrection
        {
            get
            { 
                return this.dont_reapply_wavelength_correction; 
            }
            set
            {
                this.dont_reapply_wavelength_correction = value;
                this.ResetAll();
            }
        }

        public int LevenbergMarquardtMaxIterations
        {
            get
            {
                return this.levenberg_marquardt_max_iterations;
            }
            set
            {
                this.levenberg_marquardt_max_iterations = value;
                this.UpdateLevenbergMarquardtOptions();
                this.ResetAll();
            }
        }

        public double LevenbergMarquadtTolerance
        { 
            get
            {
                return this.levenberg_marquardt_tolerance;
            }
            set
            {
                this.levenberg_marquardt_tolerance = value;
                this.UpdateLevenbergMarquardtOptions();
                this.ResetAll();
            }
        }
    }
}
