// bytran -|- spectral calculations for portable devices using the HITRAN database
//
// Developed by Dzianis Pliutau (Denis Plutov) and Kostya Roslyakov
// www.bytran.org | bytran@bytran.org
// Copyright (c) 2016 Dzianis Pliutau
// Distributed under the MIT license
//
// The MIT License (MIT)
// Copyright (c) 2016 Dzianis Pliutau
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
// is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.



// Object to contain the information pertaining to a single spectrum
#include "spectrum.h"

Spectrum::Spectrum()
{
    // The wavenumber (in cm-1) and wavelength points at the start of the spectrum, end of the spectrum and in the middle
    // The starting wavenumber is smaller than the end wavenumber, but the starting wavelength is larger than
    // the end wavenumber because startMicron corresponds to the startWn and endMicron corresponds to the endWn
    this->startWn = 0;
    this->middleWn = 0;
    this->endWn = 0;
    this->startMicron = 0;
    this->middleMicron = 0;
    this->endMicron = 0;

    // Value of the data main grid index closest to the center wavenumber of the spectral line
    this->closestMidIndex = 0;

    // Total number of points in the line data as well as the position of the middle point
    // The total number of points is always odd, this way the middle point is always symmetrical
    this->midIndex = 0;  // The number of the middle point (in the center of the points distribution)
    this->startIndex = 0;  // Index in the wavenumber array grid corresponding to the minilmum wavenumber value

    // One dimentional array with the spectral data (results of the calculation)
    this->y.resize(0);

    // Array with the values for the horizontal axis (for the case when the values are not equidistant)
    this->x.resize(0);
}

// The wavenumber (in cm-1) and wavelength points at the start of the spectrum, end of the spectrum and in the middle
// The starting wavenumber is smaller than the end wavenumber, but the starting wavelength is larger than
// the end wavenumber because startMicron corresponds to the startWn and endMicron corresponds to the endWn
double Spectrum::getStartWn() { return this->startWn; }
void Spectrum::setStartWn(double newStartWn) { this->startWn = newStartWn ; }
double Spectrum::getMiddleWn() { return this->middleWn; }
void Spectrum::setMiddleWn(double newMiddleWn) { this->middleWn = newMiddleWn; }
double Spectrum::getEndWn() { return this->endWn; }
void Spectrum::setEndWn(double newEndWn) { this->endWn = newEndWn; }
double Spectrum::getStartMicron() { return this->startMicron; }
void Spectrum::setStartMicron(double newStartMicron) { this->startMicron = newStartMicron; }
double Spectrum::getMiddleMicron() { return this->middleMicron; }
void Spectrum::setMiddleMicron(double newMiddleMicron) { this->middleMicron = newMiddleMicron; }
double Spectrum::getEndMicron() { return this->endMicron; }
void Spectrum::setEndMicron(double newEndMicron) { this->endMicron = newEndMicron; }

// Value of the data main grid index closest to the center wavenumber of the spectral line
int Spectrum::getClosestMidIndex() { return this->closestMidIndex; }
void Spectrum::setClosestMidIndex(int newClosestMidIndex) { this->closestMidIndex = newClosestMidIndex; }

// Total number of points in the line data as well as the position of the middle point
// The total number of points is always odd, this way the middle point is always symmetrical
int Spectrum::getMidIndex() { return this->midIndex; }  // The number of the middle point (in the center of the points distribution)
void Spectrum::setMidIndex(int newMidIndex) { this->midIndex = newMidIndex; }
int Spectrum::getStartIndex() { return this->startIndex; }  // Index in the wavenumber array grid corresponding to the minilmum wavenumber value
void Spectrum::setStartIndex(int newStartIndex) { this->startIndex = newStartIndex; }
int Spectrum::getEndIndex() { return this->endIndex; }
void Spectrum::setEndIndex(int newEndIndex) { this->endIndex = newEndIndex; }

// Getting and setting Y at a specific index
double Spectrum::getYAt(int index) { return this->y[index]; }
void Spectrum::setYAt(int index, double value) { this->y[index] = value; }

// Getting and setting X at a specific index
double Spectrum::getXAt(int index) { return this->x[index]; }
void Spectrum::setXAt(int index, double value) { this->x[index] = value; }

// One dimentional array with the spectral data (results of the calculation)
QVector<double> *Spectrum::getY() { return &(this->y); }
void Spectrum::setY(QVector<double> *newY)
{
    this->y.resize(newY->count());
    this->y = *newY;
}

// Array with the values for the horizontal axis (for the case when the values are not equidistant)
QVector<double> *Spectrum::getX() { return &(this->x); }
void Spectrum::setX(QVector<double> *newXValues)
{
    this->x.resize(newXValues->count());
    this->x = *newXValues;
}

// Getting and setting the all data zero variable value
double Spectrum::getMaxValue() { return this->maxValue; }
void Spectrum::setMaxValue(double newMaxValue) { this->maxValue = newMaxValue; }
double Spectrum::getMinValue() { return this->minValue; }
void Spectrum::setMinValue(double newMinValue) { this->minValue = newMinValue; }
