LAMPCAE/src/PluginWBFZExchangePlugin/LAMPDataShowClass.cpp

115 lines
3.8 KiB
C++
Raw Normal View History

2024-03-18 01:05:42 +00:00
#include "LAMPDataShowClass.h"
#include "ui_LAMPDataShowClass.h"
LAMPDataShowClass::LAMPDataShowClass(QWidget *parent)
: QMainWindow(parent)
{
ui=new Ui::LAMPDataShowClassClass;
ui->setupUi(this);
2024-03-18 01:05:42 +00:00
// 添加菜单项
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 = FileOpenMenu->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->clear();
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) {
2024-03-18 01:05:42 +00:00
int nx = complexMatrix.rows(); // 行数
int ny = complexMatrix.cols(); // 列数
// 创建 Color Map
QCPColorMap* colorMap = new QCPColorMap(customPlot->xAxis, customPlot->yAxis);
2024-03-18 01:05:42 +00:00
colorMap->data()->setSize(nx, ny); // 设置 Color Map 的大小
colorMap->data()->setRange(QCPRange(0, nx), QCPRange(0, ny)); // 设置坐标轴的范围
2024-03-18 01:05:42 +00:00
// 填充数据
for (int xIndex = 0; xIndex < nx; ++xIndex) {
for (int yIndex = 0; yIndex < ny; ++yIndex) {
2024-03-18 01:05:42 +00:00
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);
2024-03-18 01:05:42 +00:00
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);
2024-03-18 01:05:42 +00:00
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)
{
DebugInfo("LAMPDataShowClass::load_complex_data\n");
ComplexDataShowNode* node = new ComplexDataShowNode();
node->bangdindWindows(this);
node->TaskXmlPath = path;
if (!isExists(node->TaskXmlPath)) {
return;
}
else {}
node->OpenData(node->TaskXmlPath);
this->add_DataTree(node); DebugInfo("this->add_DataTree(node)\n");
node->ExcuteTask();
}
void LAMPDataShowClass::on_action_actionLoad_triggered() {
}