三维显示进行修改

This commit is contained in:
anxinglong 2026-05-20 17:53:49 +08:00
parent 3a8825beb9
commit 7b35e9b823
11 changed files with 1296 additions and 535 deletions

View File

@ -8,15 +8,21 @@
#include "csv.h"
#include "MeasureAnalysisView.h"
#include <QVector>
#include <QDateTime>
#include <QJsonObject>
#include <QJsonArray>
#include <QtConcurrent>
#include <QFutureWatcher>
#include <QMutex>
#include <QMetaType>
#include <QTextStream>
#include <QDataStream>
//using namespace CoincidenceSpectrum;
// Ui类前向声明
namespace Ui {
class ConformityAnalysis;
}
typedef struct particleCoincidenceEvent
{
int eventId;//事件ID
@ -26,77 +32,166 @@ typedef struct particleCoincidenceEvent
qulonglong timeCounter;//时间计数
}PARTICLECOINCIDENCEEVENT;
//// 用于存储三维数据
//typedef struct SurfacePoint {
// float primaryEnergy; // 初级粒子能量
// float secondaryEnergySum; // 次级粒子能量和
// int count; // 符合事件计数
//}SURFACEPOINT;
// 预计算结果结构体(仅保存计算后的数据)
struct ConformityCalculatedResult {
int conformCount; // 符合粒子数
QString dataFileName; // 原始CSV文件名
int totalEvents; // 符合事件总计数
double primaryEnergyStart; // 初级粒子能量范围-起始
double primaryEnergyEnd; // 初级粒子能量范围-结束
double secondaryEnergyStart; // 次级粒子能量范围-起始
double secondaryEnergyEnd; // 次级粒子能量范围-结束
// 板卡通道计数数据8板×4通道
int boardChannelData[MAX_BOARD][MAX_CHANNEL];
// 初级粒子计数数据
QMap<QString, int> firstParticleData;
// 三维曲面数据
QVector<SurfacePoint> surfaceData;
// 构造函数
ConformityCalculatedResult() {
memset(boardChannelData, 0, sizeof(boardChannelData));
totalEvents = 0;
primaryEnergyStart = primaryEnergyEnd = 0.0;
secondaryEnergyStart = secondaryEnergyEnd = 0.0;
}
};
Q_DECLARE_METATYPE(ConformityCalculatedResult)
// 一致性分析历史数据结构体
struct ConformityHistoryItem {
QDateTime timestamp; // 保存时间戳
QString dataFileName; // 原始CSV文件名
int conformCount; // 符合粒子数2/3/4...9
int totalEvents; // 符合事件总计数
double primaryEnergyStart; // 初级粒子能量范围-起始
double primaryEnergyEnd; // 初级粒子能量范围-结束
double secondaryEnergyStart; // 次级粒子能量范围-起始
double secondaryEnergyEnd; // 次级粒子能量范围-结束
// 板卡通道计数数据8板×4通道
int boardChannelData[MAX_BOARD][MAX_CHANNEL];
// 初级粒子计数数据
QMap<QString, int> firstParticleData;
// 三维曲面数据
QVector<SurfacePoint> surfaceData;
// JSON序列化/反序列化方法
QJsonObject toJson() const;
static ConformityHistoryItem fromJson(const QJsonObject& obj);
// 转换为预计算结果
ConformityCalculatedResult toCalculatedResult() const;
// 从预计算结果创建历史记录
static ConformityHistoryItem fromCalculatedResult(const ConformityCalculatedResult& result);
};
Q_DECLARE_METATYPE(ConformityHistoryItem)
class ConformityAnalysis : public MeasureAnalysisView
{
Q_OBJECT
private:
QMap<QString, int> m_FirstParticle;
QMap<QString, int> m_subordinate;
QVector<particleCoincidenceEvent*> m_beginVector;
QVector<particleCoincidenceEvent*> m_secondVector;
QVector<SurfacePoint> m_surfaceData;
public:
explicit ConformityAnalysis(QWidget *parent = nullptr);
~ConformityAnalysis();
virtual void InitViewWorkspace(const QString& project_name) override final;
virtual void SetAnalyzeDataFilename(const QMap<QString, QVariant>& data_files_set);
//设置csv文件路径及文件名称
void setCsvFile(QString fileName);
//读取csv文件
//读取csv文件(兼容旧代码)
void readCsv();
private slots:
void slot_InitialState();
void slot_ClickedBoard(int board,int channel);
// 符合数切换槽函数
void slot_ConformCountChanged(int index);
// 单个符合数解析完成槽函数
void onSingleParseFinished(int conformCount);
// 所有符合数解析完成槽函数
void onAllParseFinished();
// 保存单个预计算结果到历史记录(主线程执行)
void saveResultToHistory(const ConformityCalculatedResult& result);
private:
//处理板卡信息
void handleBoard();
void handleBoard(const QVector<particleCoincidenceEvent*>& data, int boardChannelData[MAX_BOARD][MAX_CHANNEL]);
//统计每个板卡的初级粒子计数
QMap<QString, int> statisticsFirstParticleQuantity();
QMap<QString, int> statisticsFirstParticleQuantity(const QVector<particleCoincidenceEvent*>& data);
//处理当前板卡初级粒子信息
QVector<particleCoincidenceEvent*> handleBasicSubordinate(int Board, int Channel);
QVector<particleCoincidenceEvent*> handleBasicSubordinate(int Board, int Channel, const QVector<particleCoincidenceEvent*>& data);
//处理次级粒子信息
QMap<QString,int> handleSubordinate(QVector<particleCoincidenceEvent*> &eventData, int Board, int Channel);
QMap<QString,int> handleSubordinate(QVector<particleCoincidenceEvent*> &eventData,int Board, int Channel);
// 获取最大值
int getMaxValue();
//计算全部的初级粒子范围 和 次级粒子范围
void calculateFirstSecondRange();
void calculateFirstSecondRange(const QVector<particleCoincidenceEvent*>& data,
double& firstStart, double& firstEnd,
double& secondStart, double& secondEnd);
//设置板卡数据信息
void setAllBoardData();
//设置符合事件相关信息
void setThreeUiData();
//全部谱图数据处理
void generateSurfaceData(const QVector<particleCoincidenceEvent*> events);
QVector<SurfacePoint> generateSurfaceData(const QVector<particleCoincidenceEvent*> events);
// 数据保存/加载核心方法(按符合数分文件)
void loadHistoryFromFile();
void saveHistoryToFile();
// 流式写入JSON零大小限制
void saveJsonStream(int conformCount, const ConformityHistoryItem& item);
// 二进制保存超大曲面数据
void saveSurfaceDataToBinary(int conformCount, const QVector<SurfacePoint>& data);
// 仅保存指定符合数的历史记录到对应文件
void saveSingleHistoryToFile(int conformCount, const ConformityHistoryItem& item);
int saveCurrentAnalysisToHistory(int conformCount);
// 根据符合数和文件名查找历史记录
int findHistoryIndex(const QString& fileName, int conformCount) const;
// 后台解析所有符合数数据(单线程串行,内存稳定)
void parseAllConformDataInBackground();
// 流式解析并计算单个符合数,内存占用<10MB
ConformityCalculatedResult streamParseAndCalculate(int conformCount, const QString& fileName);
// 显示指定符合数的数据(优先从历史/预计算缓存加载)
void displayConformData(int conformCount);
// 释放所有缓存数据
void clearAllCachedData();
// 读取csv文件仅用于点击板卡时按需加载
QVector<particleCoincidenceEvent*> readCsv(const QString& fileName);
// 释放事件数组内存
void freeEventVector(QVector<particleCoincidenceEvent*>& vec);
private:
Ui::ConformityAnalysis *ui;
QString m_fileName;
// std::vector<F2t9Order::CoincidenceEvent> m_CoincidenceEventVector;//所有的能谱符合处理
int m_boardChannel[MAX_BOARD][MAX_CHANNEL];
QVector<particleCoincidenceEvent*> _spectrumDataList;//所有的能谱符合处理
// 当前显示的符合数数据(仅保留当前显示的原始数据)
QVector<particleCoincidenceEvent*> _currentSpectrumData;
double m_dFirstStart = 0.0;//初级粒子起始能量
double m_dFirstEnd = 0.0;//初级粒子终止能量
double m_dSecondStart = 0.0;//初级粒子起始能量
double m_dSecondEnd = 0.0;//初级粒子终止能量
double m_dSecondStart = 0.0;//级粒子起始能量
double m_dSecondEnd = 0.0;//级粒子终止能量
int m_iComply = 0;//符合事件总计数
int m_currentConformCount = 2; // 当前选中的符合粒子数默认2重
// 数据持久化相关成员变量
QString _workspace; // 项目工作空间路径
QList<ConformityHistoryItem> _conformityHistoryList; // 所有历史记录列表
// 预计算结果缓存(仅保存计算后的数据,内存占用极小)
QMap<int, ConformityCalculatedResult> m_calculatedCache;
QMutex m_cacheMutex; // 缓存访问互斥锁
QMutex m_historyMutex; // 历史记录访问互斥锁
QFutureWatcher<void>* m_parseWatcher = nullptr; // 后台解析监视器
QMap<int, QString> m_conformFileMap; // 符合数->文件路径映射
bool m_isParsing = false; // 是否正在解析
};
#endif // CONFORMITYANALYSIS_H
#endif // CONFORMITYANALYSIS_H

View File

@ -13,140 +13,9 @@
<property name="windowTitle">
<string>ConformityAnalysis</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,20">
<layout class="QVBoxLayout" name="verticalLayout" stretch="20">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="topMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>通过在下图中框选区域,自动识别出符合时间进入下方列表,选择符合时间右侧界面内进行统计</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>符合时间窗:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit">
<property name="text">
<string>50</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>ns</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>26</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>修改</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>选择符合事件:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox">
<property name="minimumSize">
<size>
<width>100</width>
<height>22</height>
</size>
</property>
<item>
<property name="text">
<string>二次符合</string>
</property>
</item>
<item>
<property name="text">
<string>三次符合</string>
</property>
</item>
<item>
<property name="text">
<string>四次符合</string>
</property>
</item>
<item>
<property name="text">
<string>五次符合</string>
</property>
</item>
<item>
<property name="text">
<string>六次符合</string>
</property>
</item>
<item>
<property name="text">
<string>七次符合</string>
</property>
</item>
<item>
<property name="text">
<string>八次符合</string>
</property>
</item>
<item>
<property name="text">
<string>九次符合</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="2,4">
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="1,2">
<property name="spacing">
<number>3</number>
</property>

View File

@ -2,11 +2,25 @@
#include "ui_DetectorStatusSummary.h"
#include <QPainter>
#include <QMouseEvent>
DetectorStatusSummary::DetectorStatusSummary(QWidget *parent) :
QWidget(parent),
ui(new Ui::DetectorStatusSummary)
{
ui->setupUi(this);
// 关键:设置所有子控件背景透明,让父控件背景显示出来
setAttribute(Qt::WA_StyledBackground, false);
ui->label_name->setAttribute(Qt::WA_TranslucentBackground);
ui->label->setAttribute(Qt::WA_TranslucentBackground);
ui->label_num->setAttribute(Qt::WA_TranslucentBackground);
ui->label_begin_second->setAttribute(Qt::WA_TranslucentBackground);
ui->label_begin_second_num->setAttribute(Qt::WA_TranslucentBackground);
ui->widget->setAttribute(Qt::WA_TranslucentBackground);
ui->widget_dw->setAttribute(Qt::WA_TranslucentBackground);
// 初始化默认背景色
m_backgroundColor = QColor("#0E508A");
}
DetectorStatusSummary::~DetectorStatusSummary()
@ -14,6 +28,7 @@ DetectorStatusSummary::~DetectorStatusSummary()
delete ui;
}
// ========== 原有接口(仅修改样式表相关部分) ==========
void DetectorStatusSummary::setName(QString name)
{
ui->label_name->setText(name);
@ -43,7 +58,6 @@ void DetectorStatusSummary::setBeginSecond(QString str)
void DetectorStatusSummary::setBeginSecondNum(int num)
{
ui->label_begin_second_num->setText(QString::number(num));
}
QString DetectorStatusSummary::getBeginSecondNum()
@ -53,16 +67,8 @@ QString DetectorStatusSummary::getBeginSecondNum()
void DetectorStatusSummary::setBeginSecondWidget(bool isHide)
{
if (isHide)
{
ui->label_begin_second->hide();
ui->label_begin_second_num->hide();
}
else
{
ui->label_begin_second->show();
ui->label_begin_second_num->show();
}
ui->label_begin_second->setVisible(!isHide);
ui->label_begin_second_num->setVisible(!isHide);
}
void DetectorStatusSummary::setColorMaxValue(int maxValue)
@ -70,15 +76,10 @@ void DetectorStatusSummary::setColorMaxValue(int maxValue)
m_nMaxValue = maxValue;
}
// 关键:移除所有硬编码的样式表背景色
void DetectorStatusSummary::setInitWidgetColor()
{
QPainter p(this);
QString strqs = "min-height:35px;max-height:35px;";
p.fillRect(rect(), QColor("#0E508A")); // 仅自己区域
ui->label_name->setStyleSheet("background-color: #1E79C2;color:#FFFFFF;"+strqs);
ui->label->setStyleSheet("color:#4CA9F9;");
ui->label_num->setStyleSheet("background-color: #125997;color:#FFFFFF;font-size: 30px; font-family: Microsoft YaHei; ");
ui->widget_dw->setStyleSheet("background-color: #1B66A7;color:#FFFFFF;" + strqs);
m_backgroundColor = QColor("#0E508A");
m_useCustomColor = false;
update();
}
@ -92,118 +93,87 @@ void DetectorStatusSummary::setHideBorder()
void DetectorStatusSummary::setBackgroundColor(const QColor &color)
{
m_backgroundColor = color;
//QPainter painter(this);
//painter.setRenderHint(QPainter::Antialiasing);
////// 创建渐变背景
////QLinearGradient gradient(0, 0, width(), 0);
////gradient.setColorAt(0.0, m_backgroundColor.lighter(110));
////gradient.setColorAt(0.5, m_backgroundColor);
////gradient.setColorAt(1.0, m_backgroundColor.darker(110));
//// 绘制背景
//painter.fillRect(rect(), m_backgroundColor);
//QString strColor = QString("rgb(%1,%2,%3,1)").arg(m_backgroundColor.red()).arg(m_backgroundColor.green()).arg(m_backgroundColor.blue());
//ui.widget_dw->setStyleSheet(QString("background-color: %1;color:#FFFFFF;").arg(strColor));
//// 绘制边框
//painter.setPen(QPen(QColor(23, 99, 162), 1));
//painter.drawRect(rect().adjusted(0, 0, -1, -1));
update(); // 触发重绘
m_useCustomColor = true;
update();
}
void DetectorStatusSummary::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
// QPainter painter(this);
// painter.setRenderHint(QPainter::Antialiasing);
painter.fillRect(rect(), m_backgroundColor);
// //// 创建渐变背景
// //QLinearGradient gradient(0, 0, width(), 0);
// //gradient.setColorAt(0.0, m_backgroundColor.lighter(110));
// //gradient.setColorAt(0.5, m_backgroundColor);
// //gradient.setColorAt(1.0, m_backgroundColor.darker(110));
// // 绘制背景
// painter.fillRect(rect(), m_backgroundColor);
// QString strColor = QString("rgb(%1,%2,%3,1)").arg(m_backgroundColor.red()).arg(m_backgroundColor.green()).arg(m_backgroundColor.blue());
// ui->widget_dw->setStyleSheet(QString("background-color: %1;color:#FFFFFF;").arg(strColor));
// ui->label->setStyleSheet(QString("background-color: %1;color:#FFFFFF;").arg(strColor));
// ui->label_num->setStyleSheet(QString("background-color: %1;color:#FFFFFF;font-size: 30px; font-family: Microsoft YaHei; ").arg(strColor));
// // 绘制边框
// painter.setPen(QPen(QColor(23, 99, 162), 1));
// painter.drawRect(rect().adjusted(0, 0, -1, -1));
if (flag) {
painter.setPen(QPen(Qt::white, 2));
painter.drawRect(rect().adjusted(0, 0, -1, -1));
}
}
QColor DetectorStatusSummary::calculateGradientColor(double ratio)
{
// 四段式渐变:蓝->蓝绿->黄->橙->红
QColor color;
static const QColor blueScaleColors[5] = {
QColor(179, 212, 255), // 0.00
QColor(153, 196, 255), // 0.25
QColor( 92, 160, 255), // 0.50
QColor( 31, 124, 255), // 0.75
QColor( 0, 80, 220) // 1.00
};
if (ratio < 0.25) {
// 蓝到蓝绿
double subRatio = ratio / 0.25;
color = QColor(
14 + (51 - 14) * subRatio, // R: 14->51
80 + (102 - 80) * subRatio, // G: 80->102
138 + (153 - 138) * subRatio // B: 138->153
);
}
else if (ratio < 0.5) {
// 蓝绿到黄
double subRatio = (ratio - 0.25) / 0.25;
color = QColor(
51 + (244 - 51) * subRatio, // R: 51->244
102 + (196 - 102) * subRatio, // G: 102->196
153 + (34 - 153) * subRatio // B: 153->34
);
}
else if (ratio < 0.75) {
// 黄到橙
double subRatio = (ratio - 0.5) / 0.25;
color = QColor(
244 + (239 - 244) * subRatio, // R: 244->239
196 + (155 - 196) * subRatio, // G: 196->155
34 + (57 - 34) * subRatio // B: 34->57
);
}
else {
// 橙到红
double subRatio = (ratio - 0.75) / 0.25;
color = QColor(
239 + (255 - 239) * subRatio, // R: 239->255
155 + (51 - 155) * subRatio, // G: 155->51
57 + (76 - 57) * subRatio // B: 57->76
);
}
ratio = qBound(0.0, ratio, 1.0);
int index = static_cast<int>(ratio * 4); // 0~4
double subRatio = (ratio - index * 0.25) / 0.25;
return color;
if (index >= 4)
return blueScaleColors[4];
const QColor& c1 = blueScaleColors[index];
const QColor& c2 = blueScaleColors[index + 1];
return QColor(
c1.red() + static_cast<int>((c2.red() - c1.red()) * subRatio),
c1.green() + static_cast<int>((c2.green() - c1.green()) * subRatio),
c1.blue() + static_cast<int>((c2.blue() - c1.blue()) * subRatio)
);
}
void DetectorStatusSummary::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton && flag == false)
{
if ((ui->label_num->text().toInt() == 0 )&& (ui->label_begin_second_num->text().toInt() == 0))
return;
if (event->button() == Qt::LeftButton) {
if ((ui->label_num->text().toInt() == 0) && (ui->label_begin_second_num->text().toInt() == 0))
return;
flag = !flag;
if (flag) {
ui->widget->setStyleSheet("QWidget#widget{border: 2px solid #ffffff;}");
// 可以发出信号
emit oneclicked(objectName());
flag = true;
}
else
{
if ((ui->label_num->text().toInt() == 0 )&& (ui->label_begin_second_num->text().toInt() == 0))
return;
} else {
ui->widget->setStyleSheet("");
// 可以发出信号
emit twoClicked(objectName());
flag = false;
}
// 调用基类实现
QWidget::mousePressEvent(event);
}
QWidget::mousePressEvent(event);
}
void DetectorStatusSummary::setCountColor(int count)
{
if (m_nMaxValue <= 0) {
m_backgroundColor = QColor("#0E508A");
update();
return;
}
// 防止除零错误和数值溢出
double ratio = static_cast<double>(count) / static_cast<double>(m_nMaxValue);
ratio = qBound(0.0, ratio, 1.0);
m_backgroundColor = calculateGradientColor(ratio);
m_useCustomColor = true;
update();
}
void DetectorStatusSummary::resetColorMaxValue(int maxValue)
{
// 确保最大值至少为1防止除零错误
m_nMaxValue = qMax(1, maxValue);
}

View File

@ -41,6 +41,12 @@ public:
// 直接设置颜色由ConformanceAnalysis调用
void setBackgroundColor(const QColor& color);
// ========== 新增:粒子计数色阶专用接口 ==========
// 根据计数值自动计算并设置背景色(使用当前最大值)
void setCountColor(int count);
// 重置色阶最大值(用于自动适配模式)
void resetColorMaxValue(int maxValue);
protected:
// 添加paintEvent声明
void paintEvent(QPaintEvent *event) override;

View File

@ -52,7 +52,7 @@
<item>
<widget class="QLabel" name="label_name">
<property name="styleSheet">
<string notr="true"/>
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>TextLabel</string>
@ -97,8 +97,14 @@
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>总计数:</string>
</property>
@ -110,7 +116,7 @@
<item>
<widget class="QLabel" name="label_num">
<property name="styleSheet">
<string notr="true"/>
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>0</string>
@ -173,6 +179,9 @@
</property>
<item>
<widget class="QLabel" name="label_begin_second">
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>次级粒子计数:</string>
</property>
@ -183,6 +192,9 @@
</item>
<item>
<widget class="QLabel" name="label_begin_second_num">
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>0</string>
</property>

View File

@ -86,38 +86,35 @@ void ParticleDataStatistics::_slotClickedTwoBoard(QString board)
void ParticleDataStatistics::setWidgetData(int board, int channel, int countNum, int secondNum)
{
// 参数合法性检查(防止越界)
if (board < 1 || board > MAX_BOARD || channel < 1 || channel > MAX_CHANNEL) {
qWarning() << "setWidgetData: invalid board or channel:" << board << channel;
return;
}
DetectorStatusSummary* widget = m_widgetMap[board - 1][channel - 1];
if (widget)
{
//当板卡号和通道号都为-1时 设置为为点击状态
if(board == -1 && channel == -1)
{
widget->setCountName(QStringLiteral(u"总计数"));
widget->setNum(countNum);
widget->setBeginSecond(QStringLiteral(u"初级粒子计数"));
widget->setBeginSecondNum(secondNum);
return ;
}
//当板卡号和点击的板卡号相同时 设置为初级粒子
if(board == m_bd && channel == m_ch)
{
widget->setCountName(QStringLiteral(u"初级粒子计数"));
widget->setNum(secondNum);
widget->setBeginSecond(QStringLiteral(u"总计数"));
widget->setBeginSecondNum(countNum);
}
else//否则为次级粒子
{
widget->setCountName(QStringLiteral(u"次级粒子计数"));
widget->setNum(secondNum);
widget->setBeginSecond(QStringLiteral(u"总计数"));
widget->setBeginSecondNum(countNum);
}
if (!widget) return;
if (board == -1 && channel == -1) {
widget->setCountName(QStringLiteral(u"总计数"));
widget->setNum(countNum);
widget->setBeginSecond(QStringLiteral(u"初级计数"));
widget->setBeginSecondNum(secondNum);
widget->setCountColor(countNum); // 确保调用
return;
}
if (board == m_bd && channel == m_ch) {
widget->setCountName(QStringLiteral(u"初级计数"));
widget->setNum(secondNum);
widget->setBeginSecond(QStringLiteral(u"总计数"));
widget->setBeginSecondNum(countNum);
widget->setCountColor(secondNum); // 确保调用
} else {
widget->setCountName(QStringLiteral(u"次级计数"));
widget->setNum(secondNum);
widget->setBeginSecond(QStringLiteral(u"总计数"));
widget->setBeginSecondNum(countNum);
widget->setCountColor(secondNum); // 确保调用
}
}
@ -130,8 +127,18 @@ void ParticleDataStatistics::setInitWidgetData(int board, int channel, int count
}
widget->setCountName(QStringLiteral(u"总计数"));
widget->setNum(countNum);
widget->setBeginSecond(QStringLiteral(u"初级粒子计数"));
widget->setBeginSecond(QStringLiteral(u"初级计数"));
widget->setBeginSecondNum(secondNum);
// 设置初始总计数色阶
widget->setCountColor(countNum);
}
void ParticleDataStatistics::setAllWidgetColorMaxValue(int maxValue)
{
for (int bd = 0; bd < MAX_BOARD; bd++) {
for (int ch = 0; ch < MAX_CHANNEL; ch++) {
m_widgetMap[bd][ch]->resetColorMaxValue(maxValue);
}
}
}

View File

@ -47,6 +47,7 @@ public:
void handleBoard(std::vector<F2t9Order::SpectrumData> eventData);
//设置数据
void setCoincidenceEvent(const F2t9Order::CoincidenceEvent &CoincidenceEvent);
void setAllWidgetColorMaxValue(int maxValue);
private:
// 初始化映射表

View File

@ -9,6 +9,7 @@ ThreeDDisplay::ThreeDDisplay(QWidget *parent) :
_init3DSurface();
// 初始化颜色渐变
initColorGradient();
connect(ui->comboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(slot_currentIndexChanged(int)));
}
ThreeDDisplay::~ThreeDDisplay()
@ -310,6 +311,29 @@ void ThreeDDisplay::setComplyWithEvent(double value)
ui->lineEdit_count->setText(QString::number(value));
}
void ThreeDDisplay::setBasicParticle(const QString& startStr, const QString& endStr)
{
ui->lineEdit_begin_start->setText(startStr);
ui->lineEdit_begin_end->setText(endStr);
}
void ThreeDDisplay::setSecondParticle(const QString& startStr, const QString& endStr)
{
ui->lineEdit_second_start->setText(startStr);
ui->lineEdit_second_end->setText(endStr);
}
void ThreeDDisplay::setComplyWithEvent(const QString& countStr)
{
ui->lineEdit_count->setText(countStr);
}
int ThreeDDisplay::getComboBoxIndex()
{
return ui->comboBox->currentIndex();
}
/*--------------------设置颜色---------------------------*/
// 初始化颜色渐变
void ThreeDDisplay::initColorGradient()
@ -531,3 +555,8 @@ QColor ThreeDDisplay::getCustomColor(double ratio)
return QColor("#FFD4D7");
}
}
void ThreeDDisplay::slot_currentIndexChanged(int index)
{
emit emitCurrentIndexChanged(index);
}

View File

@ -34,7 +34,13 @@ public:
void setSecondParticle(double startValue,double endValue);
//设置符合事件计数
void setComplyWithEvent(double value);
//设置曲面图数据
void setBasicParticle(const QString& startStr, const QString& endStr);
void setSecondParticle(const QString& startStr, const QString& endStr);
void setComplyWithEvent(const QString& countStr);
//获取几次符合
int getComboBoxIndex();
private:
void _init3DSurface();
void _addAnnotations();
@ -64,7 +70,11 @@ private:
// 高亮管理
void highlightSelectedDetector(const QString& selectedName = "");
private slots:
void slot_currentIndexChanged(int index);
signals:
void emitCurrentIndexChanged(int index);
private:
Ui::ThreeDDisplay *ui;

View File

@ -51,6 +51,57 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>选择符合事件:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox">
<item>
<property name="text">
<string>二次符合</string>
</property>
</item>
<item>
<property name="text">
<string>三次符合</string>
</property>
</item>
<item>
<property name="text">
<string>四次符合</string>
</property>
</item>
<item>
<property name="text">
<string>五次符合</string>
</property>
</item>
<item>
<property name="text">
<string>六次符合</string>
</property>
</item>
<item>
<property name="text">
<string>七次符合</string>
</property>
</item>
<item>
<property name="text">
<string>八次符合</string>
</property>
</item>
<item>
<property name="text">
<string>九次符合</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
@ -91,7 +142,7 @@
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5" stretch="0,0,2,0,2,0,2">
<layout class="QVBoxLayout" name="verticalLayout_5" stretch="2,0,2,0,2">
<property name="spacing">
<number>3</number>
</property>
@ -107,46 +158,6 @@
<property name="bottomMargin">
<number>40</number>
</property>
<item>
<widget class="QWidget" name="widget_6" native="true">
<property name="styleSheet">
<string notr="true">QWidget#widget_6{
border-bottom: 1px solid #1763a2;
}</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="topMargin">
<number>20</number>
</property>
<property name="bottomMargin">
<number>20</number>
</property>
<item>
<widget class="QLabel" name="label_5">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>选择的符合事件相关信息展示:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<property name="leftMargin">
@ -166,7 +177,17 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_begin_start"/>
<widget class="QLabel" name="lineEdit_begin_start">
<property name="minimumSize">
<size>
<width>106</width>
<height>21</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_7">
@ -176,7 +197,17 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_begin_end"/>
<widget class="QLabel" name="lineEdit_begin_end">
<property name="minimumSize">
<size>
<width>106</width>
<height>21</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
@ -232,7 +263,17 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_second_start"/>
<widget class="QLabel" name="lineEdit_second_start">
<property name="minimumSize">
<size>
<width>106</width>
<height>21</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_11">
@ -242,7 +283,17 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_second_end"/>
<widget class="QLabel" name="lineEdit_second_end">
<property name="minimumSize">
<size>
<width>106</width>
<height>21</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_9">
@ -304,7 +355,17 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_count"/>
<widget class="QLabel" name="lineEdit_count">
<property name="minimumSize">
<size>
<width>150</width>
<height>21</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">