// 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
#ifndef SPECTRUM_H
#define SPECTRUM_H

#include <QVector>

class Spectrum
{
public:
    Spectrum();

public:

    // 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 getStartWn();
    void setStartWn(double newStartWn);
    double getMiddleWn();
    void setMiddleWn(double newMiddleWn);
    double getEndWn();
    void setEndWn(double newEndWn);
    double getStartMicron();
    void setStartMicron(double newStartMicron);
    double getMiddleMicron();
    void setMiddleMicron(double newMiddleMicron);
    double getEndMicron();
    void setEndMicron(double newEndMicron);

    // Value of the data main grid index closest to the center wavenumber of the spectral line
    int getClosestMidIndex();
    void setClosestMidIndex(int 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 getMidIndex();    // The number of the middle point (in the center of the points distribution)
    void setMidIndex(int newMidIndex);
    int getStartIndex();  // Index in the wavenumber array grid corresponding to the minilmum wavenumber value
    void setStartIndex(int newStartIndex);
    int getEndIndex();
    void setEndIndex(int newEndIndex);

    // One dimentional array with the spectral data (results of the calculation)
    QVector<double> *getY();
    void setY(QVector<double> *newY);

    // Getting and setting Y at a specific index
    double getYAt(int index);
    void setYAt(int index, double value);

    // Array with the values for the horizontal axis (for the case when the values are not equidistant)
    QVector<double> *getX();
    void setX(QVector<double> *newXValues);

    // Getting and setting X at a specific index
    double getXAt(int index);
    void setXAt(int index, double value);

    // Getting and setting the minimum and maximum values
    double getMaxValue();
    void setMaxValue(double newMaxValue);
    double getMinValue();
    void setMinValue(double newMinValue);

private:

    // 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 startWn;
    double middleWn;
    double endWn;
    double startMicron;
    double middleMicron;
    double endMicron;

    // Value of the data main grid index closest to the center wavenumber of the spectral line
    int closestMidIndex;

    // 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 midIndex;  // The number of the middle point (in the center of the points distribution)
    int startIndex;  // Index in the wavenumber array grid corresponding to the minilmum wavenumber value
    int endIndex;  // Ending index for the spectral line

    // One dimentional array with the spectral data (results of the calculation)
    QVector<double> y;

    // Array with the values for the horizontal axis (for the case when the values are not equidistant)
    QVector<double> x;

    // Boolean variable indicating that all data for the current spectrum is zero
    double maxValue;
    double minValue;

};

#endif // SPECTRUM_H
