// 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 stores curently active total pressure units and performs conversion from / to the default pressure units to the current pressure units
#ifndef CONCPRESSUNITSCONVERT_H
#define CONCPRESSUNITSCONVERT_H

#include <QString>

class ConcPressUnitsConvert
{
public:

    ConcPressUnitsConvert();

    // Method to get and set the current total pressure units
    quint8 getPressUnits();
    void setPressUnits(quint8 newPressUnits);

    // Method to get the abbreviated string representation of the current units
    QString getCurrPressUnitsAbbrevStr();

    // Method to get the abbreviated string representation of the current combined units
    QString getCurrCombinedUnitsAbbrevStr();

    // Getting and setting the concentration units
    quint8 getConcUnits();
    void setConcUnits(quint8 newConcUnits);

    // Method to get the combined units number
    quint8 getCombinedUnits();
    void setCombinedUnits(quint8 newCombinedUnits);

    // Method to convert from default Pressure units to current Pressure units
    double fromDefaultToCurrentPressUnits(double defaultValue);
    // Method to convert from the current Pressure units to the default Pressure units
    double fromCurrentToDefaultPressUnits(double currentValue);

    // Method to convert from specified Pressure units to the default Pressure units
    double fromSpecifiedToDefaultPressUnits(quint8 fromUnits, double fromValue);
    // Method to convert from default Pressure units to the specified Pressure units
    double fromDefaultToSpecifiedPressUnits(double defaultValue, quint8 toPressUnits);

    // Method to convert from default Concentration units to current Concentration units
    double fromDefaultToCurrentConcUnits(double defaultUnitsConcValue, double totalPressAtm);
    // Method to convert from the current Concentration units to the default Concentration units
    double fromCurrentToDefaultConcUnits(double currenUnitsConctValue, double totalPressAtm);

private:

    // Pressuere and concentration units (the concentration units are used to specify the partial pressure of molecules)
    quint8 pressUnits;  // 0 - Atmospheres, atm;  1 - Millibar, mbar;  2 - Torr, Torr;  3 - Pascal, Pa;  4 - Punds per square inch, psi;

    // The internal default for storing the internal concentration of molecules is Parts Per Million by Volume (PPMV) as the total pressure.
    quint8 concUnits;   // 0 - Percent concentration,  1 - Parts per million (ppmv),  2 - Regular pressure used to specify conc (the default internal in the mbar)

};

#endif // CONCPRESSUNITSCONVERT_H
