comac_desk_app/PostProcessing/Graph2D.cpp

108 lines
5.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "Graph2D.h"
#include "ElaMessageBar.h"
#include "Graph2DSettings.h"
#include "ElaTheme.h"
#include "SelectDatatDialog.h"
#include "DataChosenListDialog.h"
#include "Curve2DPlotor.h"
namespace pst
{
Graph2D::Graph2D(QWidget* parent) :
QWidget(parent)
{
QHBoxLayout* layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setStretch(0, 1);
layout->setStretch(1, 0);
/// @brief 测试代码
QStringList _thetaComboList1{ "-180deg", "-90deg", "0deg", "90deg", "180deg" };
QStringList _thetaComboList2{ "-360deg", "-180deg", "0deg", "90deg", "180deg" };
QStringList _thetaComboList3{ "0deg", "-270deg", "-180deg", "-90deg", "0deg", "90deg", "180deg", "270deg" };
QStringList _thetaComboList4{ "360deg", "270deg", "180deg", "90deg", "0deg", "-90deg", "-180deg", "-270deg" };
QList<QPair<QString, QList<QString>>> m_FixedVariableValueList = { {"theta", _thetaComboList1 }, { "phi", _thetaComboList2 }, { "degree", _thetaComboList3 }, { "fre", _thetaComboList4 } };
//QList<QPair<QString, QList<double>>> dataList{};
//auto data1 = qMakePair(QString("AAA"), QList<double>{ 1, 2, 3, 4, 5 });
//auto data2 = qMakePair(QString("BBB"), QList<double>{ 2, 3, 4, 5, 6 });
//auto data3 = qMakePair(QString("VVV"), QList<double>{ 3, 4, 5, 6, 7});
//auto data4 = qMakePair(QString("CCC"), QList<double>{ 4, 5, 6, 7, 8 });
//dataList << data1 << data2 << data3 << data4 << data1 << data2 << data3 << data4;
////顶级选择数据对话框
//m_selecetDataDialog = new SelectDatatDialog();
//m_selecetDataDialog->setFixedSize(400, 400);
//m_selecetDataDialog->moveToCenter();
//m_selecetDataDialog->show();
//m_selecetDataDialog->setDialogTitle("方向性");
//m_selecetDataDialog->setDataList(dataList);
//m_selecetDataDialog->updateUI();
//////次级选择数据对话框
//DataChosenListDialog* m_dataChosenListDialog = new DataChosenListDialog(this);
//m_dataChosenListDialog->setFixedSize(400, 400);
//m_dataChosenListDialog->moveToCenter();
//QList<QString> data{ "-180deg", "-90deg", "0deg", "90deg", "180deg" };
//m_dataChosenListDialog->setData(data);
//m_dataChosenListDialog->show();
//m_dataChosenListDialog->updateUI();
//QList<int> indexs{ 1, 2 };
//m_dataChosenListDialog->setSelctedIndexs(indexs);
//_aboutPage->show();
m_customPlot = new Curve2DPlotor(this);
m_settings = new Graph2DSettings(this);
//先连接信号和槽然后设置m_settings的数值以使其直接作用到m_customPlot
initConnections();
m_settings->setCurrentFixedValueIndex(2);
m_settings->setFixedVariableValue(m_FixedVariableValueList);
m_settings->setCategaryData({ "雷内","fe ","tianl" });
m_settings->updateUI();
/// @brief 测试代码结束
layout->addWidget(m_customPlot);
layout->addWidget(m_settings);
}
Graph2D::~Graph2D()
{
if (m_customPlot)
{
delete m_customPlot;
m_customPlot = nullptr;
}
}
void Graph2D::initConnections()
{
connect(m_settings, &Graph2DSettings::signal_XAxisTitleNameChanged,
this, [this](const QString& titleName) {m_customPlot->setXAxisTitleName(titleName); });
connect(m_settings, &Graph2DSettings::signal_XAxisTitleFontFamilyChanged,
this, [this](const QString& family) {m_customPlot->setXAxisFontFamily(family); });
connect(m_settings, &Graph2DSettings::signal_XAxisTitleFontSizeChanged,
this, [this](int size) {m_customPlot->setXAxisFontSize(size); });
connect(m_settings, &Graph2DSettings::signal_XAxisMinValueChanged,
this, [this](double minValue) {m_customPlot->setXAxisRangeMin(minValue); });
connect(m_settings, &Graph2DSettings::signal_XAxisMaxValueChanged,
this, [this](double maxValue) {m_customPlot->setXAxisRangeMax(maxValue); });
connect(m_settings, &Graph2DSettings::signal_XAxisStepValueChanged,
this, [this](double step) {m_customPlot->setXAxisRangeStep(step); });
connect(m_settings, &Graph2DSettings::signal_YAxisTitleNameChanged,
this, [this](const QString& titleName) {m_customPlot->setYAxisTitleName(titleName); });
connect(m_settings, &Graph2DSettings::signal_YAxisTitleFontFamilyChanged,
this, [this](const QString& family) {m_customPlot->setYAxisFontFamily(family); });
connect(m_settings, &Graph2DSettings::signal_YAxisTitleFontSizeChanged,
this, [this](int size) {m_customPlot->setYAxisFontSize(size); });
connect(m_settings, &Graph2DSettings::signal_YAxisMinValueChanged,
this, [this](double minValue) {m_customPlot->setYAxisRangeMin(minValue); });
connect(m_settings, &Graph2DSettings::signal_YAxisMaxValueChanged,
this, [this](double maxValue) {m_customPlot->setYAxisRangeMax(maxValue); });
connect(m_settings, &Graph2DSettings::signal_YAxisStepValueChanged,
this, [this](double step) {m_customPlot->setYAxisRangeStep(step); });
}
}