入射粒子时间集成,修改显示大小问题
This commit is contained in:
parent
209be2b040
commit
364f4e6c1a
|
|
@ -122,6 +122,15 @@ void MeasureAnalysisTreeView::onNodeDoubleClicked(const QModelIndex& index)
|
|||
}
|
||||
}
|
||||
} break;
|
||||
case AnalysisType::ParticleInTimeView: {
|
||||
MeasureAnalysisProjectModel* project_model = _model->GetProjectModel(project_name);
|
||||
if (project_model) {
|
||||
auto file_name = project_model->GetParticleEnergyDataFilename();
|
||||
if ( !file_name.isEmpty() ) {
|
||||
data_files_set[QStringLiteral(u"粒子能量数据")] = file_name;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include <QMap>
|
||||
#include "MeasureAnalysisDataTableView.h"
|
||||
#include "MeasureAnalysisParticleCountPlotView.h"
|
||||
#include "ParticleInjectTimeAnalysis.h"
|
||||
|
||||
MeasureAnalysisView *MeasureAnalysisView::NewAnalyzeView(AnalysisType view_type)
|
||||
{
|
||||
|
|
@ -76,7 +77,7 @@ MeasureAnalysisView *MeasureAnalysisView::NewAnalyzeView(AnalysisType view_type)
|
|||
// new_view->setDeleteOnClose(false);
|
||||
} break;
|
||||
case AnalysisType::ParticleInTimeView: {
|
||||
new_view = new MeasureAnalysisDataTableView;
|
||||
new_view = new ParticleInjectTimeAnalysis;
|
||||
new_view->setDeleteOnClose(false);
|
||||
} break;
|
||||
case AnalysisType::ParticleTimeDiffView: {
|
||||
|
|
|
|||
|
|
@ -6,21 +6,22 @@
|
|||
#include <QwtPlotCurve>
|
||||
#include <QwtPlotMarker>
|
||||
#include <QwtPlotZoneItem>
|
||||
#include <QwtPlotCanvas>
|
||||
#include <QwtLegend>
|
||||
#include <QwtText>
|
||||
#include <cmath>
|
||||
#include <QtMath>
|
||||
#include "CustomQwtPlot.h"
|
||||
#include <QDebug>
|
||||
#include <GlobalDefine.h>
|
||||
|
||||
ParticleInjectTimeAnalysis::ParticleInjectTimeAnalysis(QWidget *parent) :
|
||||
MeasureAnalysisView(parent),
|
||||
ui(new Ui::ParticleInjectTimeAnalysis)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
InitUi();
|
||||
// 获取当前可执行文件的路径
|
||||
QString Path = QCoreApplication::applicationDirPath();
|
||||
m_AllData = getParticleInjectTimeData(Path + "/data.csv");
|
||||
setData(m_AllData);
|
||||
|
||||
}
|
||||
|
||||
ParticleInjectTimeAnalysis::~ParticleInjectTimeAnalysis()
|
||||
|
|
@ -35,7 +36,11 @@ void ParticleInjectTimeAnalysis::InitViewWorkspace(const QString &project_name)
|
|||
|
||||
void ParticleInjectTimeAnalysis::SetAnalyzeDataFilename(const QMap<QString, QVariant> &data_files_set)
|
||||
{
|
||||
|
||||
if(!data_files_set.isEmpty())
|
||||
{
|
||||
m_AllData = getParticleInjectTimeData(data_files_set.first().toString());
|
||||
setData(m_AllData);
|
||||
}
|
||||
}
|
||||
|
||||
void ParticleInjectTimeAnalysis::setData(QVector<ParticleInjectTime> data)
|
||||
|
|
@ -61,16 +66,16 @@ void ParticleInjectTimeAnalysis::setData(QVector<ParticleInjectTime> data)
|
|||
}
|
||||
|
||||
// 创建曲线并设置数据
|
||||
QwtPlotCurve *curve = new QwtPlotCurve("正弦曲线");
|
||||
QwtPlotCurve *curve = new QwtPlotCurve();
|
||||
curve->setSamples(x, y);
|
||||
|
||||
// 将曲线添加到 CustomQwtPlot 中(会自动分配颜色)
|
||||
plot->AddCurve(curve);
|
||||
// 设置坐标轴范围和标题
|
||||
plot->setAxisScale(QwtPlot::xBottom, 0, x.last());
|
||||
plot->setAxisScale(QwtPlot::yLeft,minValue , maxValue);
|
||||
// plot->setAxisScale(QwtPlot::xBottom, 0, x.last());
|
||||
// plot->setAxisScale(QwtPlot::yLeft,minValue , maxValue);
|
||||
plot->setAxisTitle(QwtPlot::xBottom, "粒子序号");
|
||||
plot->setAxisTitle(QwtPlot::yLeft, "粒子时间");
|
||||
LOG_INFO(QStringLiteral(u"%1数据读取完毕.").arg(this->GetViewName()));
|
||||
|
||||
// 刷新绘图
|
||||
plot->replot();
|
||||
|
|
@ -79,7 +84,7 @@ void ParticleInjectTimeAnalysis::setData(QVector<ParticleInjectTime> data)
|
|||
|
||||
QVector<ParticleInjectTime> ParticleInjectTimeAnalysis::getParticleInjectTimeData(QString path)
|
||||
{
|
||||
QVector<ParticleInjectTime> records;
|
||||
QVector<ParticleInjectTime> records;
|
||||
QFile file(path);
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
|
|
@ -129,6 +134,7 @@ QVector<ParticleInjectTime> ParticleInjectTimeAnalysis::getParticleInjectTimeDat
|
|||
}
|
||||
|
||||
file.close();
|
||||
|
||||
return records;
|
||||
}
|
||||
|
||||
|
|
@ -136,5 +142,29 @@ void ParticleInjectTimeAnalysis::InitUi()
|
|||
{
|
||||
plot = new CustomQwtPlot();
|
||||
plot->SetXaxisDragScale(true);
|
||||
ui->verticalLayout->addWidget(plot);
|
||||
setupPlot();
|
||||
ui->verticalLayout_2->addWidget(plot);
|
||||
}
|
||||
|
||||
void ParticleInjectTimeAnalysis::setupPlot()
|
||||
{
|
||||
plot->setCanvasBackground(Qt::white);
|
||||
QwtPlotCanvas* canvas = qobject_cast<QwtPlotCanvas*>(plot->canvas());
|
||||
canvas->setFrameStyle(QFrame::NoFrame);
|
||||
|
||||
plot->setAxisTitle(QwtPlot::xBottom, QString(QStringLiteral(u"道址")));
|
||||
plot->setAxisTitle(QwtPlot::yLeft, QString(QStringLiteral(u"计数")));
|
||||
// set axis auto scale
|
||||
plot->setAxisAutoScale(QwtPlot::xBottom, true);
|
||||
plot->setAxisAutoScale(QwtPlot::yLeft, true);
|
||||
// 启用网格线
|
||||
plot->enableAxis(QwtPlot::xBottom);
|
||||
plot->enableAxis(QwtPlot::yLeft);
|
||||
|
||||
// 设置QWT图例
|
||||
QwtLegend* legend = new QwtLegend();
|
||||
legend->setDefaultItemMode(QwtLegendData::ReadOnly);
|
||||
plot->insertLegend(legend, QwtPlot::RightLegend);
|
||||
|
||||
plot->SetXaxisDragScale(true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ public:
|
|||
QVector<ParticleInjectTime> getParticleInjectTimeData(QString path);
|
||||
private:
|
||||
void InitUi();
|
||||
void setupPlot();
|
||||
|
||||
private:
|
||||
Ui::ParticleInjectTimeAnalysis *ui;
|
||||
|
|
|
|||
|
|
@ -13,10 +13,7 @@
|
|||
<property name="windowTitle">
|
||||
<string>ParticleInjectTimeAnalysis</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,100">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
|
|
@ -124,7 +121,16 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
|
|
@ -138,7 +144,7 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout"/>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@ MOC_DIR = $${BUILD_MOC}/$${TARGET}/moc
|
|||
UI_DIR = $${BUILD_UI}/$${TARGET}/ui
|
||||
|
||||
INCLUDEPATH += \
|
||||
$${PWD}/MeasureAnalysisParticleCountPlotView
|
||||
$${PWD}/MeasureAnalysisParticleCountPlotView \
|
||||
$${PWD}/ParticleInjectTimeView
|
||||
|
||||
DEPENDPATH += \
|
||||
$${PWD}/MeasureAnalysisParticleCountPlotView
|
||||
$${PWD}/MeasureAnalysisParticleCountPlotView \
|
||||
$${PWD}/ParticleInjectTimeView
|
||||
|
||||
SOURCES += \
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user