#include "LAMPDataShowClass.h" LAMPDataShowClass::LAMPDataShowClass(QWidget *parent) : QMainWindow(parent) { ui.setupUi(this); // 添加菜单项 QMenu* FileOpenMenu = this->ui.menuFile->addMenu(u8"打开"); QAction* action_openfile_tiff = FileOpenMenu->addAction(u8"tiff文件"); // 添加菜单项 QObject::connect(action_openfile_tiff, SIGNAL(triggered()), this, SLOT(on_action_openfile_tiff_triggered())); QMenu* ComplexFileOpenMenu = this->ui.menuFile->addMenu(u8"打开复数数据"); QAction* action_openfile_tiff_complex = ComplexFileOpenMenu->addAction(u8"tiff文件"); // 添加菜单项 QObject::connect(action_openfile_tiff_complex, SIGNAL(triggered()), this, SLOT(on_action_openfile_tiff_complex_triggered())); QAction* action_openfile_envi_complex = ComplexFileOpenMenu->addAction(u8"envi文件"); // 添加菜单项 QObject::connect(action_openfile_envi_complex, SIGNAL(triggered()), this, SLOT(on_action_openfile_envi_complex_triggered())); this->setContextMenuPolicy(Qt::CustomContextMenu); this->ui.listWidgetContent->setContextMenuPolicy(Qt::CustomContextMenu); } LAMPDataShowClass::~LAMPDataShowClass() {} void LAMPDataShowClass::add_DataTree(TaskNode* node) { QListWidgetItem* itemtemp = new QListWidgetItem(this->ui.listWidgetContent); itemtemp->setSizeHint(node->sizeHint()); this->ui.listWidgetContent->setItemWidget(itemtemp, node); this->ui.listWidgetContent->addItem(itemtemp); } void ShowComplexMatrixPlot(QCustomPlot* customPlot, const Eigen::MatrixXcd& complexMatrix) { int nx = complexMatrix.rows(); // 行数 int ny = complexMatrix.cols(); // 列数 // 创建 Color Map QCPColorMap* colorMap = new QCPColorMap(customPlot->xAxis, customPlot->yAxis); colorMap->data()->setSize(nx, ny); // 设置 Color Map 的大小 colorMap->data()->setRange(QCPRange(0, nx), QCPRange(0, ny)); // 设置坐标轴的范围 // 填充数据 for (int xIndex = 0; xIndex < nx; ++xIndex) { for (int yIndex = 0; yIndex < ny; ++yIndex) { double magnitude = std::abs(complexMatrix(xIndex, yIndex)); // 或者使用 std::arg() 获取相位 colorMap->data()->setCell(xIndex, yIndex, magnitude); } } colorMap->setGradient(QCPColorGradient::gpJet); colorMap->rescaleDataRange(true); customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); customPlot->rescaleAxes(); customPlot->replot(); } void LAMPDataShowClass::on_action_openfile_tiff_triggered() { } void LAMPDataShowClass::on_action_openfile_envi_triggered() { } void LAMPDataShowClass::on_action_openfile_tiff_complex_triggered() { ComplexDataShowNode* node = new ComplexDataShowNode(); node->bangdindWindows(this); node->TaskXmlPath = getOpenFilePath(nullptr, u8"打开复数数据", u8" tiff文件(*.tiff ,*.tif)"); if (!isExists(node->TaskXmlPath)) { return; } else {} node->OpenData(node->TaskXmlPath); this->add_DataTree(node); node->ExcuteTask(); } void LAMPDataShowClass::on_action_openfile_envi_complex_triggered() { ComplexDataShowNode* node = new ComplexDataShowNode(); node->bangdindWindows(this); node->TaskXmlPath = getOpenFilePath(nullptr, u8"打开复数数据", u8"envi文件(*.dat ) "); if (!isExists(node->TaskXmlPath)) { return; } else {} node->OpenData(node->TaskXmlPath); this->add_DataTree(node); node->ExcuteTask(); } void LAMPDataShowClass::load_complex_data(QString path) { ComplexDataShowNode* node = new ComplexDataShowNode(); node->bangdindWindows(this); node->TaskXmlPath = path; if (!isExists(node->TaskXmlPath)) { return; } else {} node->OpenData(node->TaskXmlPath); this->add_DataTree(node); node->ExcuteTask(); }