#pragma once
///
/// 控制模型整体平移转换
/// 1. 平移方法
///		a. 矢量平移法
///		b. 重心设置
/// 2. 旋转方法
///		a. 重心转换方法，根据坐标系 
///		b. 
///

#ifndef OCCT_MODEL_OPERATOR_H
#define OCCT_MODEL_OPERATOR_H
#include "AllHead.h"
#include "ui_OCCTModelOperator.h"
#include "OCCTBaseOperaorClass.h"
class OCCTModelOperator : public QDialog
{
	Q_OBJECT

public:
	OCCTModelOperator(QString TopoName,QWidget *parent = nullptr, Handle(AIS_InteractiveContext) myContext = nullptr);
	~OCCTModelOperator();
	
	void setTopoDs_Shape(TopoDS_Shape ds);

	TopoDS_Shape getTopoDs_Shape();
	TopoDS_Shape getTopoDs_ShapeBAK();
	Handle(AIS_InteractiveContext) myContext; 
	Handle(AIS_InteractiveObject) getAIS();
	Handle(AIS_InteractiveObject) getAISBAK();
 
private:													  
	Ui::OCCTModelOperatorClass ui;							  
															  
public: 													  
	TopoDS_Shape Datashape; // 处理控制的模型 
	TopoDS_Shape DataShapeBAK;
	Handle(AIS_InteractiveObject) Data_AIS; // 处理模型
	QString ModelName;




	double Move_From_X;
	double Move_From_Y;
	double Move_From_Z;
	double Move_To_X;
	double Move_To_Y;
	double Move_To_Z;

	double Rotation_Center_X;
	double Rotation_Center_Y;
	double Rotation_Center_Z;

	double Rotation_angle_X; // 绕X轴旋转角度
	double Rotation_angle_Y;
	double Rotation_angle_Z;

	double ScaleRefrencePoint_X;
	double ScaleRefrencePoint_Y;
	double ScaleRefrencePoint_Z;
	double ScaleDouble;

signals: // 信号域
	void ResultExportCopyAndCreateNew( OCCTModelOperator*); // 创建并复制模型
	void ResultExport(OCCTModelOperator*); // 返回修改后的模型
	void RefreshResult(OCCTModelOperator*); // 模型重新绘制

public slots:
	void on_lineEdit_Move_From_X_returnPressed();
	void on_lineEdit_Move_From_Z_returnPressed();
	void on_lineEdit_Move_From_Y_returnPressed();
	void on_lineEdit_Move_To_X_returnPressed();
	void on_lineEdit_Move_To_Y_returnPressed();
	void on_lineEdit_Move_To_Z_returnPressed();
	void on_lineEdit_Rotation_Center_X_returnPressed();
	void on_lineEdit_Rotation_Center_Y_returnPressed();
	void on_lineEdit_Rotation_Center_Z_returnPressed();
	void on_lineEdit_Rotation_Axis_X_returnPressed();
	void on_lineEdit_Rotation_Axis_Y_returnPressed();
	void on_lineEdit_Rotation_Axis_Z_returnPressed();
	void on_lineEdit_Scale_returnPressed();
 
	void on_lineEdit_Scale_refrence_point_X_returnPressed();
	void on_lineEdit_Scale_refrence_point_Y_returnPressed();
	void on_lineEdit_Scale_refrence_point_Z_returnPressed();
	void on_lineEdit_ScaleValue_returnPressed();



	void on_radioButton_Auto_toggled(bool flag);
	void on_radioButton_NoAuto_toggled(bool flag);

	// 按钮
	void on_pushButton_ok_clicked();
	void on_pushButton_apply_clicked();
	void on_pushButton_Cancel_clicked();
	//
	void PreViewOperator(); // 预处理
	void ApplyModel();
	void ProcesssModel();
	void ExcuteOperator(); // 执行替换操作
	void UpdataVariable();

	// 更新缩放参数
	void UpdateScaleRefrencepoint();
	void toString();

	// 
protected:
	// 重写 closeEvent 函数来捕获关闭事件
	void closeEvent(QCloseEvent* event) override {
		// 在关闭事件发生时执行你想要的操作
		qDebug() << u8"模型操作类 is closing!";
		this->myContext->Remove(this->Data_AIS, Standard_False);
		this->myContext->UpdateCurrentViewer();
		this->Datashape.Nullify();
		this->Data_AIS.Nullify();
		// 调用父类的 closeEvent 函数，以确保正确处理窗口的关闭
		QDialog::closeEvent(event);
	};
};															  

#endif