
#pragma once

#ifndef IMAGESHOWDIALOGCLASS_H
#define IMAGESHOWDIALOGCLASS_H
#include "imageshowtool_global.h"
#include "BaseConstVariable.h"
#include <QDialog>
#include <QLabel>
#include "qcustomplot.h"
#include <Eigen/Core>
#include <Eigen/Dense>


//===========================
// 定义需要绘制的图像的类型
//===========================
enum LAMPDATASHOWCLASS {
	LAMPGraph,
	LAMPColorMap,
	LAMPScatterStyle,
	NOWINDOWS
};

namespace Ui {
	class ImageShowDialogClass;
};




//===========================
// 构建游标类型
// 1. 单纯的描述游标，主要用来展示坐标，还有当前数据信息
// 2. 区域性描述游标，通过线，等用来展示某一个区域的信息
//===========================
class   IMAGESHOWTOOL_EXPORT   ImageShowCursorDesClass : public QDialog
{
	Q_OBJECT
public:
	QLabel* label;

 
public:
	ImageShowCursorDesClass(QWidget* parent = nullptr);
	~ImageShowCursorDesClass();
public slots:
	void updateCursorContent(QString content);
signals:
	bool windowsClose();
protected:
	void closeEvent(QCloseEvent* event) override;

};


class  IMAGESHOWTOOL_EXPORT ImageShowCursorLineClass :public QDialog {
	Q_OBJECT
public:
	QMenuBar* menubar;
	QMenu* DataList;
	QMenu* RemoveList;

	QCustomPlot* customPlot;
	bool tracerEnable;
 
	QCPItemTracer* tracer;	//游标
	QCPItemText* tracerYText;	//图标标签
	QCPItemText* tracerXText; //游标标签
	QMap<QString, QCPAbstractPlottable*> m_graphMap;
	QMap<QString, QAction*> data_action_map;
	QString TrackName;

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

public:
	void loadPlotLine(QVector<double> xs, QVector<double> dataValues, QString Name);
	void UpdatePlotLine(QVector<double> xs, QVector<double> dataValues, QString Name);
	void updateCursor(QMouseEvent* event);


public slots:
	void xAxisRangeChanged(QCPRange);
	void yAxisRangeChanged(QCPRange);
	void on_SwichTracerGraph_Name();
	void load_new_compare_line();

signals:
	bool windowsClose();
protected:
	void closeEvent(QCloseEvent* event) override;
};




//===========================
// 构建数据展示窗口
// 1. 单纯的描述游标，主要用来展示坐标，还有当前数据信息
// 2. 区域性描述游标，通过线，等用来展示某一个区域的信息
//===========================
class   IMAGESHOWTOOL_EXPORT ImageShowDialogClass : public QDialog
{
	Q_OBJECT
private:
	LAMPDATASHOWCLASS graphclass;
public:
	QMenuBar* menubar;
	QStatusBar* statusbar;
	ImageShowCursorDesClass* desCursor; // 描述游标
	ImageShowCursorLineClass* HlineCursor;// H 游标
	ImageShowCursorLineClass* VlineCursor;// V 游标
 
	bool desCursorflag;
	bool HlineCursorflag;
	bool VlineCursorflag;

	QCustomPlot* m_plot;
	QCPItemTracer* tracer;	//游标
 
public:
	QMap<QString, QCPAbstractPlottable*> m_graphMap;
public:
	ImageShowDialogClass(QWidget *parent = nullptr);
	~ImageShowDialogClass();
public:

	void PlotLine(QVector<double> xs, QVector<double> ys, QString Name);

	void Scatter(double dx, double dy);
	void Scatter(QVector<double> xs, QVector<double> ys);
	void load_double_MatrixX_data(Eigen::MatrixXd data, QString name);
	void load_double_MatrixX_data(Eigen::MatrixXd X,Eigen::MatrixXd Y,Eigen::MatrixXd data, QString name);
	void load_double_data(float* data, long rows, long cols, QString name);
	void load_double_data(double* data, long rows, long cols, QString name);
	void load_double_data(float* Xs,float* Ys,float* data, long rows, long cols, QString name);

	void remove_Data( QString name);

	LAMPDATASHOWCLASS getGraphClass(size_t i = 0);
	size_t getGraphCount();
private:
	Ui::ImageShowDialogClass* ui;

public slots:
	void updateCursor(QMouseEvent* event);


public slots: // cursor
	void on_action_cursor_enable_trigged();
	void on_action_descursor_close_trigged();
	void on_action_Hlinecursor_close_trigged();
	void on_action_VVlinecursor_close_trigged();
};


#endif
