From edc5e4d7935a0c53e47ae4851842034cc13926fb Mon Sep 17 00:00:00 2001 From: zhangsheng Date: Tue, 29 Jul 2025 21:08:57 +0800 Subject: [PATCH] add IntegratRMS --- AddChannel.cpp | 2 +- ChannelSetting.cpp | 2 +- CharacteristicList.cpp | 4 +++ CustomGraphicsItemGroup.h | 60 +++++++++++++++++++++++++++++++++++++++ realtimeform.cpp | 6 ++-- 5 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 CustomGraphicsItemGroup.h diff --git a/AddChannel.cpp b/AddChannel.cpp index 48d7b27..139d074 100644 --- a/AddChannel.cpp +++ b/AddChannel.cpp @@ -76,7 +76,7 @@ void CAddChannel::on_comboBox_channel_currentTextChanged(const QString &arg1) ui->comboBox_charac->addItem("推导峰值"); ui->comboBox_charac->addItem("峰值"); ui->comboBox_charac->addItem("速度峰值"); - ui->comboBox_charac->addItem("速度有效值"); + ui->comboBox_charac->addItem("积分有效值"); ui->comboBox_charac->addItem("峰值因子"); }else if(g_ChannelBaseInfo[i].channelType == "VELOCITY"){ diff --git a/ChannelSetting.cpp b/ChannelSetting.cpp index ac02b22..c5a5cb7 100644 --- a/ChannelSetting.cpp +++ b/ChannelSetting.cpp @@ -63,7 +63,7 @@ CChannelSetting::CChannelSetting(QWidget *parent) : ui->channelTypeCombox->addItems(ChannelTypeList); m_itemList << "是" << "否" ; - m_DisPlayerList << "峰峰值" << "有效值" << "峰值" <<"平均值"; + m_DisPlayerList << "峰峰值" << "有效值" << "峰值" <<"平均值" << "诊断峰峰值" << "积分有效值"; ui->comboBox_sensorICP->addItems(m_itemList); ui->comboBox_defaultDisplay->clear(); ui->comboBox_defaultDisplay->addItems(m_DisPlayerList); diff --git a/CharacteristicList.cpp b/CharacteristicList.cpp index 299b98a..7fa0c84 100644 --- a/CharacteristicList.cpp +++ b/CharacteristicList.cpp @@ -89,6 +89,10 @@ void CCharacteristicList::DisPlayCharacteristic() } }else if(g_ChannelBaseInfo[i].defaultDisplay == "转速"){ model->setData(model->index(j,2,QModelIndex()),QString::number(g_Charateristic[j].speedRPM,'f',g_Charateristic[j].ChUnitDot)); + }else if(g_ChannelBaseInfo[i].defaultDisplay == "诊断峰峰值"){ + model->setData(model->index(j,2,QModelIndex()),QString::number(g_Charateristic[j].DiagnosisPk2Pk,'f',g_Charateristic[j].ChUnitDot)); + }else if(g_ChannelBaseInfo[i].defaultDisplay == "积分有效值"){ + model->setData(model->index(j,2,QModelIndex()),QString::number(g_Charateristic[j].IntegratRMS,'f',g_Charateristic[j].ChUnitDot)); } if(g_ChannelBaseInfo[i].boardType == "5"){ model->setData(model->index(j,2,QModelIndex()),QString::number(g_Charateristic[j].DCValues,'f',g_Charateristic[j].ChUnitDot)); diff --git a/CustomGraphicsItemGroup.h b/CustomGraphicsItemGroup.h new file mode 100644 index 0000000..66e6cc9 --- /dev/null +++ b/CustomGraphicsItemGroup.h @@ -0,0 +1,60 @@ +#ifndef CUSTOMGRAPHICSITEMGROUP_H +#define CUSTOMGRAPHICSITEMGROUP_H +#include +#include + +class RoundedGraphicsItemGroup : public QGraphicsItemGroup { +public: + RoundedGraphicsItemGroup(QGraphicsItem *parent = nullptr) + : QGraphicsItemGroup(parent), selected(false) { + //setFlag(QGraphicsItem::ItemIsSelectable, true); // 使该项可选中 + } + + // 设置圆角半径 + void setCornerRadius(qreal radius) { + cornerRadius = radius; + prepareGeometryChange(); + } + + QRectF boundingRect() const override { + return QGraphicsItemGroup::boundingRect(); + } + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override { + Q_UNUSED(option) + Q_UNUSED(widget) + + // 启用抗锯齿 + painter->setRenderHint(QPainter::Antialiasing, true); + + // 绘制圆角矩形背景 + painter->setBrush(QBrush(QColor(255, 255, 255))); + painter->setPen(Qt::NoPen); + painter->drawRoundedRect(boundingRect(), cornerRadius, cornerRadius); + + // 绘制选中效果 + if (isSelected()) { + QPen pen(QColor(36,93,155), 3); // 蓝色边框 + painter->setPen(pen); + painter->setBrush(Qt::NoBrush); + painter->drawRoundedRect(boundingRect().adjusted(1.5, 1.5, -1.5, -1.5), cornerRadius, cornerRadius); + } + } + +protected: + void mousePressEvent(QGraphicsSceneMouseEvent *event) override { + QGraphicsItemGroup::mousePressEvent(event); + update(); // 更新选中效果 + } + + void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override { + QGraphicsItemGroup::mouseReleaseEvent(event); + update(); // 更新选中效果 + } + +private: + qreal cornerRadius = 10.0; // 默认圆角半径 + bool selected; // 是否被选中 +}; + +#endif // CUSTOMGRAPHICSITEMGROUP_H diff --git a/realtimeform.cpp b/realtimeform.cpp index 23d62ea..a60ee49 100644 --- a/realtimeform.cpp +++ b/realtimeform.cpp @@ -336,9 +336,9 @@ void CRealTimeForm::on_addchannel(channelBaseInfo channelbaseInfo, QString str) } else if (str == "最大正向峰值" || str == "最大负向峰值" || str == "诊断峰峰值" || str == "平均值") { pTextUnits = new QGraphicsTextItem(channelbaseInfo.sensorEngineeringUnit); - } else if (str == "速度峰值" || str == "速度有效值") { + } else if (str == "速度峰值" || str == "速度有效值" || str == "积分有效值") { pTextUnits = new QGraphicsTextItem("mm/s"); - } else { + }else { pTextUnits = new QGraphicsTextItem(channelbaseInfo.sensorEngineeringUnit); } } else if (channelbaseInfo.channelType == "PROXIMETER") { @@ -1112,7 +1112,7 @@ void CRealTimeForm::UpdateCharacteristic(QVector<_Charateristic> &m_vecCharateri str = QString("%1").arg(QString::number(m_vecCharateristic[i].MonitorPk2Pk, 'f', m_vecCharateristic[i].ChUnitDot)); } else if (itemData2 == "诊断峰峰值") { str = QString("%1").arg(QString::number(m_vecCharateristic[i].DiagnosisPk2Pk, 'f', m_vecCharateristic[i].ChUnitDot)); - } else if (itemData2 == "速度有效值" || itemData2 == "位移有效值") { + } else if (itemData2 == "积分有效值" || itemData2 == "位移有效值") { str = QString("%1").arg(QString::number(m_vecCharateristic[i].IntegratRMS, 'f', m_vecCharateristic[i].ChUnitDot)); } else if (itemData2 == "速度峰值" || itemData2 == "位移峰值") { str = QString("%1").arg(QString::number(m_vecCharateristic[i].IntegratPk2Pk2, 'f', m_vecCharateristic[i].ChUnitDot));