// 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 Hiperscan.Spectroscopy;

namespace Hiperscan.Spectroscopy.Processing
{
    public partial class ReferenceBlockProcessor 
        : SpectrumProcessor
    {

        public Spectrum DarkReference
        {
            get
            {
                return this.dark_reference;
            }
            set
            {
                this.dark_reference = value?.Clone();
                this.ConfigureLimitBandwidth(this.dark_reference);
                if (value != null)
                { 
                    this.reference_dark_intensity = new DarkIntensity(this.dark_reference);
                    this.sample_dark_intensity = this.reference_dark_intensity;
                }
                else
                { 
                    this.reference_dark_intensity = null;
                    this.sample_dark_intensity = null;
                }

                this.recalc_fix_two_glass_oxide = true;
                this.ResetExternalReferences();
            }
        }

        public Spectrum FixTwoGlassOxideReference
        {
            get
            {
                if (this.recalc_fix_two_glass_oxide && this.fix_two_glass_oxide != null)
                {
                    if (this.reference_dark_intensity != null)
                        this.fix_two_glass_oxide.DarkIntensity = new DarkIntensity(this.reference_dark_intensity);
                    if (this.white_reference != null)
                        this.fix_two_glass_oxide.Reference = this.white_reference.Clone();
                    this.recalc_fix_two_glass_oxide = false;
                }
                return this.fix_two_glass_oxide;
            }
            set
            {
                this.fix_two_glass_oxide = value?.Clone();
                this.ConfigureLimitBandwidth(this.fix_two_glass_oxide);
                this.ResetExternalReferences();
            }
        }
    }
}
