#ifndef PEAKPOINT_H
#define PEAKPOINT_H

#include <QPointF>

#include "filemanager.h"

namespace PeakPoint{
void setExperimentData(const QVector<FileManager::ExperimentData>&);

QPair<QPointF,QPointF> getStartAndEndPoint();
void setRegionPointX(const float,const float);
QPointF findClosestPointByX(const float);
QPointF findPeakPoint();
QString textFormatPeakPoint(const float enthalpyValue,
                   const float peakValue,
                   const float startPoint,
                   const float endPoint);
QString textFormatNumbericalLabel(const QPointF);
QPair<QPointF,QPointF> calculateStartAndEndPoint();
double calculateArea();

//private
void updateStartEndPoint();
QPair<QPointF,QPointF> calculateMaxDiffPointLeft();
QPair<QPointF,QPointF> calculateMaxDiffPointRight();
enum MaxDiffPointDetailType{
    Left,
    Right
};
QPair<QPointF,QPointF> calculateMaxDiffPointDetail(const MaxDiffPointDetailType type);

QPointF calculateIntersection(const QPointF p1,const QPointF p2,
                              const QPointF p3, const QPointF p4);
QVector<QPointF> getPeakPointGroup();

extern QVector<FileManager::ExperimentData> _dataVtr;
extern QPointF _peakPoint;
extern QPointF _leftSelectedPoint,_rightSelectedPoint;
}

#endif // PEAKPOINT_H
