LAMPCAE/src/PluginWBFZExchangePlugin/WBFZExchangePlugin.cpp

288 lines
10 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include "IO/IOConfig.h"
#include "ModelData/modelDataBase.h"
#include "ModuleBase/ThreadControl.h"
#include "ModuleBase/ThreadTaskManager.h"
#include "WBFZExchangePlugin.h"
#include "DialogPCLStatisticalRemoveFilter.h"
#include "DialogPCLRadiusOutlierRemoval.h"
#include "DialogPCLGuassFilter.h"
#include "DialogPCLBilateralFilter.h"
#include "DialogPCLGPMesh.h"
#include "DialogPCLPoissonMesh.h"
#include "Settings/BusAPI.h"
#include <QFileInfo>
#include "Common/DebugLogger.h"
#include "AllHead.h"
#include "TaskTreeClass.h"
#include "TaskNodeList.h"
#include "EchoTableEditWindow.h"
#include "SqliteDBMainWindow.h"
#include "LAMPImageCreateClass.h"
#include "OCCTLine2Face.h"
//#include "dialogechodatashow.h"
namespace WBFZ {
GUI::MainWindow* WBFZ::WBFZExchangePlugin::_mainwindow = nullptr;
WBFZExchangePlugin::WBFZExchangePlugin(GUI::MainWindow* m)
{
_describe = "WBFZExchangePlugin Installed Successfully";
_mainwindow = m;
// 点云操作
connect(_mainwindow, SIGNAL(on_pclStatisticalRemoveFilter(GUI::MainWindow*)), this,
SLOT(pclStatisticalRemoveFilter(GUI::MainWindow*)));
connect(_mainwindow, SIGNAL(on_pclRadiusOutlierRemoval(GUI::MainWindow*)), this,
SLOT(pclRadiusOutlierRemoval(GUI::MainWindow*)));
connect(_mainwindow, SIGNAL(on_pclGuassFilter(GUI::MainWindow*)), this,
SLOT(pclGuassFilter(GUI::MainWindow*)));
connect(_mainwindow, SIGNAL(on_pclBilateralFilter(GUI::MainWindow*)), this,
SLOT(pclBilateralFilter(GUI::MainWindow*)));
connect(_mainwindow, SIGNAL(on_pclGPMesh(GUI::MainWindow*)), this,
SLOT(pclGPMesh(GUI::MainWindow*)));
connect(_mainwindow, SIGNAL(on_pclPoissonMesh(GUI::MainWindow*)), this,
SLOT(pclPoissonMesh(GUI::MainWindow*)));
// FEKO
connect(_mainwindow, SIGNAL(on_actionImageSetting(GUI::MainWindow*)), this,
SLOT(actionImageSetting(GUI::MainWindow*)));
connect(_mainwindow, SIGNAL(on_actionFEKO2csv(GUI::MainWindow*)), this,
SLOT(actionFEKO2csv(GUI::MainWindow*)));
connect(_mainwindow, SIGNAL(on_actionScatterExport(GUI::MainWindow*)), this,
SLOT(actionScatterExport(GUI::MainWindow*)));
connect(_mainwindow, SIGNAL(on_actionFEKOImage(GUI::MainWindow*)), this,
SLOT(actionFEKOImage(GUI::MainWindow*)));
connect(_mainwindow, SIGNAL(on_actionantScatteringFEKOSetting(GUI::MainWindow*)), this,
SLOT(actionantScatteringFEKOSetting(GUI::MainWindow*)));
// 属性表
connect(_mainwindow, SIGNAL(on_actionAttriutionDBShow(GUI::MainWindow*)), this,
SLOT(actionAttriutionDBShow(GUI::MainWindow*)));
connect(_mainwindow,SIGNAL(on_actionImageShowToolTriggleSIGNAL(GUI::MainWindow* )),this,SLOT(actionImageShowToolShow(GUI::MainWindow*)));
connect(_mainwindow,SIGNAL(on_actionRCShowToolSIGNAL(GUI::MainWindow* )),this,SLOT(actionactionRCShowTool(GUI::MainWindow*)));
connect(_mainwindow,SIGNAL(actionGenerateImportModelScript(int ,GUI::MainWindow* ,QStringList,QStringList ,QString )),this,SLOT(actionGenerateImportModelScript(int ,GUI::MainWindow* ,QStringList,QStringList ,QString )));
connect(_mainwindow,SIGNAL(on_actionLine2FaceSIGNAL()),this,SLOT(actionLine2FaceSLOT()));
DebugInfo("WBFZExchangePlugin::WBFZExchangePlugin has init \n");
}
bool WBFZExchangePlugin::install()
{
if(_mainwindow == nullptr)
return false;
PluginBase::install();
DebugInfo("WBFZExchangePlugin::WBFZExchangePlugin has install PluginBase::install\n ");
return true;
}
bool WBFZExchangePlugin::uninstall()
{
PluginBase::uninstall();
return true;
}
void WBFZExchangePlugin::reTranslate(QString) {}
GUI::MainWindow* WBFZExchangePlugin::getMWpt()
{
return _mainwindow;
}
// 事件绑定
void WBFZExchangePlugin::pclStatisticalRemoveFilter(GUI::MainWindow* m)
{
DebugInfo("WBFZExchangePlugin::pclStatisticalRemoveFilter has init\n");
MainWidget::DialogPCLStatisticalRemoveFilter dlg(m);
dlg.exec();
}
void WBFZExchangePlugin::pclRadiusOutlierRemoval(GUI::MainWindow* m)
{
DebugInfo("WBFZExchangePlugin::pclRadiusOutlierRemoval has init\n");
MainWidget::DialogPCLRadiusOutlierRemoval dlg(m);
dlg.exec();
}
void WBFZExchangePlugin::pclGuassFilter(GUI::MainWindow* m)
{
DebugInfo("WBFZExchangePlugin::pclGuassFilter has init\n");
MainWidget::DialogPCLGuassFilter dlg(m);
dlg.exec();
}
void WBFZExchangePlugin::pclBilateralFilter(GUI::MainWindow* m)
{
DebugInfo("WBFZExchangePlugin::pclBilateralFilter has init\n");
MainWidget::DialogPCLBilateralFilter dlg(m);
dlg.exec();
}
void WBFZExchangePlugin::pclGPMesh(GUI::MainWindow* m)
{
DebugInfo(" WBFZExchangePlugin::pclGPMesh has init\n");
MainWidget::DialogPCLGPMesh dlg(m);
dlg.exec();
}
// FEKO 设置
void WBFZExchangePlugin::actionImageSetting(GUI::MainWindow* m)
{
DebugInfo(" WBFZExchangePlugin::actionImageSetting has init\n");
FEKOImageSettingFun(m);
}
void WBFZExchangePlugin::actionFEKO2csv(GUI::MainWindow* m)
{
DebugInfo(" WBFZExchangePlugin::actionFEKO2csv has init\n");
FEKO2csvFun(m);
}
void WBFZExchangePlugin::actionScatterExport(GUI::MainWindow* m)
{
DebugInfo(" WBFZExchangePlugin::actionScatterExport has init\n");
ScatterExportFun(m);
}
void WBFZExchangePlugin::actionFEKOImage(GUI::MainWindow* m)
{
DebugInfo(" WBFZExchangePlugin::actionFEKOImage has init\n");
FEKOImageFun(m);
}
void WBFZExchangePlugin::actionantScatteringFEKOSetting(GUI::MainWindow* m)
{
DebugInfo(" WBFZExchangePlugin::actionantScatteringFEKOSetting has init\n");
antScatteringFEKOSettingFun(m);
}
void WBFZExchangePlugin::actionAttriutionDBShow(GUI::MainWindow* m) {
DebugInfo(" WBFZExchangePlugin::actionAttriutionDBShow has init\n");
SqliteDBMainWindow* w = new SqliteDBMainWindow(m);
w->show();
}
void WBFZExchangePlugin::actionImageShowToolShow(GUI::MainWindow* m) {
DebugInfo(" WBFZExchangePlugin::actionImageShowToolShow has init\n");
LAMPDataShowClass* w = new LAMPDataShowClass(m);
w->show();
}
void WBFZExchangePlugin::actionactionRCShowTool(GUI::MainWindow* m) {
// DebugInfo(" WBFZExchangePlugin::actionactionRCShowTool has init\n");
// WBCLFZ::DialogEchoDataShow* w = new WBCLFZ::DialogEchoDataShow(m);
// w->show();
}
void WBFZExchangePlugin::pclPoissonMesh(GUI::MainWindow* m) {
DebugInfo(" WBFZExchangePlugin::pclPoissonMesh has init\n");
MainWidget::DialogPCLPoissonMesh dlg(m);
dlg.exec();
}
void WBFZExchangePlugin::actionGenerateImportModelScript(int TaskID, GUI::MainWindow* m,
QStringList stlPath,QStringList geoList,
QString scriptPath)
{
scriptPath = scriptPath.replace(".lua", "_model_init_script.lua");
// 写入导入模型脚本
Setting::BusAPI::instance()->findTask(TaskID)->setState(Setting::TaskDescState::Running);
// 创建lua脚本内存
QString scripttext = "";
scripttext =scripttext +"app=cf.GetApplication()"+"\n";
scripttext =scripttext +"project=app.Project --- get current project"+"\n";
for(QString filepath:stlPath){
QFileInfo fileinfo(filepath);
QString filename = fileinfo.fileName();
scripttext =scripttext +QString("project.Importer.Mesh:Import(\"%1\")").arg(filepath);
scripttext=scripttext+"\n";
}
for(QString filepath:geoList){
QFileInfo fileinfo(filepath);
QString filename = fileinfo.fileName();
scripttext =scripttext +QString("project.Importer.Geometry:Import(\"%1\")").arg(filepath);
scripttext=scripttext+"\n";
}
// 创建文件对象
QFile file(scriptPath);
// 打开文件以供写入,如果文件不存在将创建新文件
if(file.open(QIODevice::WriteOnly | QIODevice::Text)) {
// 创建文本流并设置编码为UTF-8
QTextStream stream(&file);
stream.setCodec("UTF-8");
stream << scripttext;
// 关闭文件
file.close();
QMessageBox::information(m, u8"提示",u8"文件写入成功:\t"+scriptPath);
Setting::BusAPI::instance()->findTask(TaskID)->setState(Setting::TaskDescState::Finished);
} else {
qDebug() << "Could not open file for writing.";
QMessageBox::information(nullptr, QString::fromUtf8(u8"提示"),
QString::fromUtf8(u8"文件写入失败"));
Setting::BusAPI::instance()->findTask(TaskID)->setState(Setting::TaskDescState::Failed);
}
}
void WBFZExchangePlugin::actionLine2FaceSLOT() {
MergeSelectLine2Face(WBFZExchangePlugin::getMWpt());
}
} // namespace WBFZ
void Register(GUI::MainWindow* m, QList<Plugins::PluginBase*>* ps)
{
Plugins::PluginBase* p = new WBFZ::WBFZExchangePlugin(m);
ps->append(p);
}
void FEKOImageSettingFun(GUI::MainWindow* m)
{
DebugInfo(" FEKOImageSettingFun has init\n");
// 参数界面设置
FEKOImageSettingTaskNodeClass* imageNode = new FEKOImageSettingTaskNodeClass();
imageNode->TaskWindows->setOCCTDocument(m);
DebugInfo(" FEKOImageSettingFun has init imageNode\n");
QString xmlfilepath = getSaveFilePath(m, QString::fromUtf8(u8"任务xml"), QString::fromUtf8(u8"xml文件 (*.xml)"));
imageNode->loadXmlFile(xmlfilepath);
DebugInfo(" FEKOImageSettingFun has init loadXmlFile\n");
imageNode->TaskWindows->setOCCTDocument(m);
//this->addTaskNode(imageNode);
DebugInfo(" FEKOImageSettingFun has init ExcuteTask\n");
imageNode->ExcuteTask();
}
void FEKO2csvFun(GUI::MainWindow* m)
{
DebugInfo(" FEKO2csvFun has init\n");
QString xmlfilepath = getSaveFilePath(m, QString::fromUtf8(u8"设置FEKO结果导入任务xml"),
QString::fromUtf8(u8"xml文件 (*.xml)"));
DebugInfo(" xml file path %s \n",xmlfilepath.toStdString().c_str());
FEKOResultImportTaskNode* fekoresulttask = new FEKOResultImportTaskNode();
fekoresulttask->loadXmlFile(xmlfilepath);
fekoresulttask->ExcuteTask();
}
void ScatterExportFun(GUI::MainWindow* m)
{
DebugInfo(" ScatterExportFun has init\n");
EchoTableEditWindow* echoEditwindow = new EchoTableEditWindow(m);
echoEditwindow->show();
}
void FEKOImageFun(GUI::MainWindow* m)
{
DebugInfo(" FEKOImageFun has init\n");
LAMPImageCreateClass* imagewindows = new LAMPImageCreateClass;
imagewindows->on_pushButton_loadfekosimulationxml_clicked();
imagewindows->show();
}
void antScatteringFEKOSettingFun(GUI::MainWindow* m)
{
DebugInfo(" antScatteringFEKOSettingFun has init\n");
FEKOScatterSettingTaskNodeClass* scattertasknode=new FEKOScatterSettingTaskNodeClass();
scattertasknode->TaskWindows->setDocument3d(m);
QString xmlfilepath = getSaveFilePath(m, QString::fromUtf8(u8"任务xml"),
QString::fromUtf8(u8"xml文件 (*.xml)"));
scattertasknode->loadXmlFile(xmlfilepath);
scattertasknode->TaskWindows->setDocument3d(m);
//this->addTaskNode(scattertasknode);
DebugInfo(" antScatteringFEKOSettingFun ExcuteTask t\n");
scattertasknode->ExcuteTask();
}
// FEKO 参数调用