#pragma once
///
/// 用于刻画当前项目所涉及到的所有任务
/// 
/// 
#ifndef TASKNODELIST_H
#define TASKNODELIST_H

#include "AllHead.h"
#include <qDebug>

#include "EchoShowProcess/EchoTableEditWindow.h"
#include "OCCViewer/CommonSample.h"
#include "OCCTopoShapeTreeViewer.h"
#include "OCCTBaseOperaorClass.h"
#include "OCCTModelOperator.h"
#include "OCCTopoShapeTreeViewer.h"

#include "OcctExportClass.h"

// 任务数据节点
#include "TaskXml/TaskTreeClass.h"
#include "ImageShowDialogClass.h"
#include "LAMP_ScatterSettingClass.h"
#include "EchoShowProcess/FEKOResultImport.h"
#include "QtSARAntModelSetting.h"

//
// 模型节点
//
class OCCTShapeModelNode : public  TaskNode {
	Q_OBJECT
public:
	Handle(AIS_Shape) Data_AIS; // 构建核心数据
	bool modelRepair;
	OCCTShapeType shapetype;
	QString Filepath;
	//QMenu* ContentListContextMenu;
	Handle(AIS_InteractiveContext) myContext;

public:
	Q_INVOKABLE OCCTShapeModelNode(QWidget* parent = nullptr);
	~OCCTShapeModelNode();
	void initContextMenu();

	void HideShape();
	void ShowShape();

	void removeDataShapeShow();
	void setContext(Handle(AIS_InteractiveContext) myContext);

	void setShape(const TopoDS_Shape& Data_Shape);

	void SaveShape(QString Filepath);

	Handle(AIS_Shape)& AIS();
	const TopoDS_Shape& Shape();
 

	bool setDataFile(QString filepath);
	bool setSaveFilePath(QString filepath);
	bool SaveFile();
	bool CheckFilePath();

	int ExcuteTask() override;
	int FinishTask() override;
	TaskNode* CopyToNew() override;

signals:
	// 自定义信号，表示复选框被双击
	void doubleClicked();
	void deleteItem(QString name);  // 删除对象
	void renameItem(QString name); // 文件重命名 
	void copyNew();
	void ShowFullExtend(const TopoDS_Shape& Shape);
	void ModelModify(OCCTShapeModelNode* item);
public slots:
	void oncheckBoxStateChanged(int state); // 双击切换状态
	void ShowContentListContextMenu(QPoint p);
	// 右键菜单
	void ShowOrHide();
	void removeItem();
	void renameItem();
	void copyItem();
	void showExtend();
	void saveItem();
	void saveAsItem();
	void ExportItem(); // 导出模型
	void TranslationObject();



protected: // 重写单双击事件
	void mouseDoubleClickEvent(QMouseEvent* event) override {
		// 检查是否是双击事件
		if (event->button() == Qt::LeftButton) {

			setChecked(!isChecked());

			emit doubleClicked();
		}
		// 将事件传递给基类处理其他可能的事件
		QCheckBox::mouseDoubleClickEvent(event);
	}
	void mousePressEvent(QMouseEvent* event) override {

		if (event->button() == Qt::LeftButton) {
			// 根据状态变化的 QCheckBox 显示相应的消息
			QString message = QString("%1 state changed to %2").arg(this->text()).arg(this->checkState() == Qt::Checked ? "Checked" : "Unchecked");
			qDebug() << "Checkbox State don't change , in click \n";
			qDebug() << message;
		}
		else { // 右键菜单单独处理
			qDebug() << u8"OCCTCheckPoint右键菜单启动 \n";
			QCheckBox::mousePressEvent(event); // 
			emit customContextMenuRequested(event->globalPos());
		}
	}
	void contextMenuEvent(QContextMenuEvent* event) override {
		emit customContextMenuRequested(event->globalPos());
	}
};

//
// 数据展示节点
//
class DataShowNode :public TaskNode { // 展示普通图像的结果
	Q_OBJECT
public:
	DataShowNode(QWidget* parent = nullptr);
	~DataShowNode();// 
public:
	QString datapath;
	ImageShowDialogClass* DataShowDockWidget;
	QMainWindow* m;
public:
	void bangdindWindows(QMainWindow* m);
	void loadData();
	void OpenData(QString TaskXmlPath);
	int ExcuteTask(); // 展示并绘制图像
public slots:
	void Load_Image();
};

//
// 复数数据展示节点
//
class ComplexDataShowNode : public TaskNode
{
	Q_OBJECT
public:
	ComplexDataShowNode(QWidget* parent = nullptr);
	~ComplexDataShowNode();
public:
	QString datapath;
	//ImageShowDialogClass* DataShowDockWidget;
	QMainWindow* m;
public:

	void bangdindWindows(QMainWindow* m);
	void loadData();
	void OpenData(QString TaskXmlPath);
	int ExcuteTask(); // 展示并绘制图像

public slots: // 参数复数

	void Load_amp_Image();
	void Load_pha_Image();
	void Load_real_Image();
	void Load_imag_Image();
	void Load_dB_Image();
};

//
// FEKO数据转换任务节点
//
class FEKOResultImportTaskNode :public  TaskNode {
	Q_OBJECT
public:
	FEKOResultImportTaskNode();
	~FEKOResultImportTaskNode();
	QString FolderPath;
	bool nearField;
	bool farField;
	QString prename;
	std::vector<QString> nearFieldNames;
	std::vector<QString> farFieldNames;
	std::vector<QString> selectFieldNames;
	QString outPath;
private:
	FEKOResultImport* TaskWindows;
public:
	virtual int ExcuteTask();
	virtual int loadXmlFile(QString xmlFilePath); // 加载任务文件,必须重写
	virtual int saveXmlFile();  // 保存任务文件，必须重写
	virtual int FinishTask() override;
public slots:
	void getExcuteTaskResult(FEKOResultImport* obj);
};

//
// FEKO成像参数任务设置节点
//
class FEKOImageSettingTaskNodeClass :public TaskNode, public FEKOBase::FEKOSimulationDataparamsHandler
{
	Q_OBJECT

public:
	FEKOImageSettingTaskNodeClass();
	~FEKOImageSettingTaskNodeClass();
public:
	QtSARAntModelSettingClass* TaskWindows; // 模型姿态设置
	//FEKOBase::FEKOSimulationSARClass simulationSetting; // 仿真参数设置
public:
	virtual int ExcuteTask() override;
	virtual int FinishTask() override;
	virtual int loadXmlFile(QString xmlFilePath); // 加载任务文件,必须重写
	virtual int saveXmlFile();  // 保存任务文件，必须重写
	QString getTaskName();

};

//
// 散射装置仿真成像
//
class FEKOScatterSettingTaskNodeClass :public TaskNode {
	Q_OBJECT
public:
	FEKOScatterSettingTaskNodeClass();
	~FEKOScatterSettingTaskNodeClass();
public:
	LAMP_ScatterSettingClass* TaskWindows; // 模型姿态设置
	//FEKOBase::FEKOSimulationSARClass simulationSetting; // 仿真参数设置
public:
	virtual int ExcuteTask();
	virtual int loadXmlFile(QString xmlFilePath); // 加载任务文件,必须重写
	virtual int saveXmlFile();  // 保存任务文件，必须重写
	QString getTaskName();
};

 



#endif