From cd829e46922c57f8675f585f371a6bc9f1f55829 Mon Sep 17 00:00:00 2001 From: "DESKTOP-450PEFP\\mainc" Date: Sat, 14 Mar 2026 11:55:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E9=87=8A=E7=BB=93=E8=AE=BA=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E9=80=89=E4=B8=AD=EF=BC=8C=E5=90=88=E5=B9=B6=E5=A4=8D?= =?UTF-8?q?=E5=90=88=E5=B1=82=E9=80=BB=E8=BE=91=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logPlus/TransparentGroupResult.cpp | 7 ++- logPlus/qmycustomplot.cpp | 90 ++++++++++++++++++++++++++++++ logPlus/qmycustomplot.h | 3 + 3 files changed, 99 insertions(+), 1 deletion(-) diff --git a/logPlus/TransparentGroupResult.cpp b/logPlus/TransparentGroupResult.cpp index b8e4ddd..e3c6560 100644 --- a/logPlus/TransparentGroupResult.cpp +++ b/logPlus/TransparentGroupResult.cpp @@ -726,7 +726,12 @@ void TransparentGroupResult::onMousePress(QMouseEvent *event) else { mDragMode = DragNone; - setSelectRect(false); + + if (event->modifiers() & Qt::ControlModifier) { + //qDebug() << "鼠标点击时按住了Ctrl键"; + } + else + setSelectRect(false); return; } } diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index 27a4ebb..3296dae 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -1247,6 +1247,9 @@ void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event) menu.addAction(QIcon(::GetImagePath() + "icon/Split.png"), "分割为层内层", this, &QMyCustomPlot::segmentationInnerLayer); menu.addAction(QIcon(::GetImagePath() + "icon/Split.png"), "分割为独立层", this, &QMyCustomPlot::segmentationIndependentLayer); menu.addAction(QIcon(::GetImagePath() + "icon/Split.png"), "拆分复合层成独立层", this, &QMyCustomPlot::splitIndependentLayer); + QMap mapsort = this->getSelectGroupResult(); + if (mapsort.size() > 1) + menu.addAction(QIcon(::GetImagePath() + "icon/decreasey.png"), "合并", this, &QMyCustomPlot::megResultLayer); } menu.exec(event->globalPos()); @@ -3682,6 +3685,18 @@ void QMyCustomPlot::addItems_Gujing() //取消选中 void QMyCustomPlot::ClearSelectItems() { + if (m_strLineName == "RESULT") + { + QMap mapsort = this->getSelectGroupResult(); + QList listGroup = mapsort.values(); + for (int i = 0; i < listGroup.size(); i++) + { + TransparentGroupResult* pGroup = listGroup.at(i); + if (pGroup == NULL) + continue; + pGroup->setSelectRect(false); + } + } //属性清空 PropertyService()->InitCurrentViewInfo(); } @@ -6934,6 +6949,21 @@ TransparentGroupResult* QMyCustomPlot::getCurGroupResult(double x_val) return pClickGroup; } +QMap QMyCustomPlot::getSelectGroupResult() +{ + QMap mapsort; + QObjectList objList = m_mapDragGroup.values(); + for (int i = 0; i < objList.size(); i++) + { + TransparentGroupResult *pGroup = qobject_cast(objList.at(i)); + if (pGroup == nullptr || !pGroup->getSelect()) + continue; + QCPRange rg = pGroup->getRange(); + mapsort.insert(-rg.upper, pGroup); + } + return mapsort; +} + void QMyCustomPlot::segmentationInnerLayer() { //获取鼠标点位置 @@ -7058,6 +7088,66 @@ void QMyCustomPlot::splitIndependentLayer() this->replot(); } +void QMyCustomPlot::megResultLayer() +{ + if (QMessageBox::information(NULL, QObject::tr("提示"), QObject::tr("合并为复合层?"), tr("是"), tr("否")) != 0) return; + // 筛选出选中的Group, 并且排序 + QMap mapsort = this->getSelectGroupResult(); + if (mapsort.size() <= 0) + return; + + // 取出Group下面的DraggableResult,并且调整 lower,删除原来选中的Group + double dupper; + double dlower; + QVector> gr; + QList listGroup = mapsort.values(); + for (int i = 0; i < listGroup.size(); i++) + { + TransparentGroupResult* pGroup = listGroup.at(i); + if (pGroup == NULL) + continue; + + if (i == 0) + { + dupper = pGroup->getRange().upper; + } + if (i == listGroup.size() - 1) + { + dlower = pGroup->getRange().lower; + } + + const QVector& vec = pGroup->getVecResult(); + const QMap& mapResult = pGroup->getMapDraggable_Result(); + + for (int k = 0; k < vec.size(); k++) + { + TransparentDraggableResult* pret = qobject_cast(mapResult.value(vec.at(k))); + if (pret == NULL) + continue; + QCPRange rg = pret->getRange(); + if (i + 1 < listGroup.size()) + { + TransparentGroupResult* pLowGroup = listGroup.at(i+1); + if (pGroup) + rg.lower = pLowGroup->getRange().upper; + } + gr << qMakePair(rg, pret->getResult()); + } + pGroup->removeAllResult(); + } + + // 生成新的Group + QString strUuid = ""; + TransparentGroupResult* pNewG = this->addResultGroup(dlower, dupper, strUuid); + strUuid = ""; + for (int i = 0; i < gr.size(); i++) + { + const QPair& r = gr.at(i); + pNewG->addResultToPlot(r.first.lower, r.first.upper, r.second, strUuid); + } + this->replot(); +} + bool QMyCustomPlot::getIsEditor() { if (m_strLineName == "RESULT") diff --git a/logPlus/qmycustomplot.h b/logPlus/qmycustomplot.h index c3b0625..59e40d1 100644 --- a/logPlus/qmycustomplot.h +++ b/logPlus/qmycustomplot.h @@ -407,9 +407,12 @@ public slots: void updateGroupZone(); //更新层号 TransparentGroupResult* getCurGroupResult(double x_val); + // 筛选出选中的Group, 并且排序 + QMap getSelectGroupResult(); void segmentationInnerLayer(); // 分割为层内层 void segmentationIndependentLayer(); // 分割为独立层 void splitIndependentLayer(); // 拆分复合层成独立层 + void megResultLayer();// 合并 bool getIsEditor(); //