#include "FITKCGNSIOInterface.h" #include "FITKCGNSReader.h" #include "FITK_Interface/FITKInterfaceMesh/FITKUnstructuredFluidMeshVTK.h" #include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h" #include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h" namespace IO { QString FITKCGNSIOInterface::getComponentName() { //返回类型名 return "IO::FITKCGNSIOInterface"; } void FITKCGNSIOInterface::setFileName(const QString& fileName) { m_fileName = fileName; } bool FITKCGNSIOInterface::exec(const int indexPort) { m_success = false; if (m_Mesh == nullptr) return false; if (m_fileName.isEmpty()) return false; //判断indexPort 1:读取 2:写出 switch (indexPort) { case 1: m_io = new FITKCGNSReader; break; case 2: m_io = nullptr; break; default: break; } if (m_io == nullptr) return false; m_io->setFileName(m_fileName); m_io->setDataObject(m_Mesh); m_io->setResultMark(&m_success); m_io->run(); //connect(m_io.getObjectPtr(), SIGNAL(taskFinishedSig(FITKThreadTask*)), this, SLOT(ioThreadFinishedSlot()), Qt::UniqueConnection); //m_io->setFileName(m_fileName); //m_io->setDataObject(m_Mesh); //m_io->setResultMark(&m_success); ////在线程运行,提交到线程池 //if (m_runInThread) // m_io->push2ThreadPool(); //else //{ // m_io->run(); // //不在线程运行,执行完读写之后直接触发结束信号 // emit ioThreadFinishedSig(); //} return m_success; } bool FITKCGNSIOInterface::isSuccess() { return m_success; } bool FITKCGNSIOInterface::isRunning() { return m_io != nullptr; } void FITKCGNSIOInterface::setMeshObj(Interface::FITKUnstructuredFluidMeshVTK * mesh) { m_Mesh = mesh; } void FITKCGNSIOInterface::setRunInThread(bool r /*= true*/) { m_runInThread = r; } void FITKCGNSIOInterface::ioThreadFinishedSlot() { emit this->ioThreadFinishedSig(); } }