#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QStatusBar>
#include <QDockWidget>

#include "oitautoanalysis.h"
#include "axissettingform.h"
#include "printpreviewform.h"
#include "centralwidget.h"
#include "leftwidget.h"
#include "experimentsettingform.h"
#include "realtimedataform.h"
#include "dataparser.h"
#include "rightwidget.h"
#include "analysissettingform.h"
#include "specificheatcomparisonmethodform.h"
#include "degreeofcrystallinityform.h"
#include "instrumentcoefficientform.h"
#include "degreeofcureform.h"
#include "oitautoanalysisparamform.h"
#include "aboutform.h"
#include "enthalpydatacorrectionform.h"
#include "coefficientselectionform.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

public slots:
    void slotContextMenuShow(const QPoint);
    void slotUpdateStatusbarMsg(const QString);

    void slotOITAutoAnalysis(const double,const double);

    void slotStartExperiment();

    void slotDeviceDisconnected();
protected:
    void closeEvent(QCloseEvent *event) override;
private slots:
    //experiment
    void on_actionConnectToDev_triggered();
    void on_actionNew_triggered();
    void on_actionStart_triggered();
    // 停止实验
    void on_actionStop_triggered();
    void on_actionReadOnly_triggered();
    void on_actionRealTimeWidget_triggered();

    void slotSaveExperimentalDataMsgBox();

    //analysis
    void on_actionNumericalLabel_triggered();
    void on_actionStartPoint_triggered();
    void on_actionStopPoint_triggered();
    void on_actionPeakSynthesisAnalysis_triggered();

    void on_actionClearAllData_triggered();
    void on_actionGlassTransition_triggered();

    void on_actionOIT_triggered();

    void on_actionSpecificHeatCompMethod_triggered();

    void on_actionDegreeOfCrystallinity_triggered();

    void on_actionInstrumentParameter_triggered();

    void on_actionOITAutoAnalysisParam_triggered();

    void on_actionOITAutoAnalysisMode_triggered();

    void on_actionTimeAxisAnalysisPCTMode_triggered();

    void on_actionDegreeOfCuring_triggered();

    void on_actionAbout_triggered();

    void on_actionEnthalpyCorrectionEdit_triggered();

    void on_actionEnthalpyCorrectionSelection_triggered();

    void on_actionPrintPreview_triggered();

    void on_actionOnsetTemperaturePoint_triggered();

    void on_actionEndsetTemperaturePoint_triggered();

    void on_actionYAxis_triggered();

    void on_actionAxisSetting_triggered();

    void on_actionSaveData_triggered();

    void on_actionSaveas_triggered();

    void on_actionLanguage_triggered();

    void on_actionSmoothness1_triggered();
    void on_actionSmoothness2_triggered();
    void on_actionSmoothness3_triggered();
    void on_actionSmoothness4_triggered();
    void on_actionSmoothness5_triggered();
    void on_actionSmoothness6_triggered();
    void on_actionSmoothness7_triggered();
    void on_actionSmoothness8_triggered();
    void on_actionSmoothness9_triggered();
    void on_actionSmoothness10_triggered();
// 原始数据
    void on_actionOriginalData_triggered();

private:
    void setAnalysisData();
    void connections();
    void setActionEnable(const bool);
    void setSubWidgetAttribute(QWidget *);

    bool saveFile(const QString fileName,const Global::Mode,
                  QString& finalFileName,const bool autoSaveFlag = false);

    void smoothness(const int level);
    QVector<Global::ExperimentData> smoothnessDetail(const int level,const QVector<Global::ExperimentData>&);
    void smoothnessExperimentData(const int level);

    void startExperiment();
    void startExperimentByDeviceInfo();

    void showMesgBox(const QString str);
private:
    bool _manuallyStopTheExperimentFlag;
    Ui::MainWindow *ui;
    CentralWidget *_centralWidget;
    EventHandler *_eventHandler;
    LeftWidget*_leftWidget;
    QDockWidget* _rightWidget;
    ExperimentSettingForm *_expertmentSettingForm;
    RealTimeDataForm* _realTimeDataForm;
    QMenu* _contextMenu;
    AnalysisSettingForm* _analysisSettingWidget;
    SpecificHeatComparisonMethodForm* _specificHeatComparisonMethodForm;
    DegreeOfCrystallinityForm * _degreeOfCrystallinityForm;
    InstrumentCoefficientForm* _instrumentCoefficientForm;
    DegreeOfCureForm *_degreeOfCureForm;
    OITAutoAnalysisParamForm* _OITAutoAnalysisParamForm;
    AboutForm *_aboutForm;
    EnthalpyDataCorrectionForm* _enthalpyDataCorrectionForm;
    CoefficientSelectionForm * _coefficientSelectionForm;
    PrintPreviewForm *_printPreviewForm;
    AxisSettingForm * _axisSettingForm;
};

#endif // MAINWINDOW_H
