1.可视解释区域,右键菜单功能:删除曲线,删除道。2.曲线属性优化

This commit is contained in:
jiayulong 2026-02-09 18:14:22 +08:00
parent 59f013452a
commit 8d555aebbe
12 changed files with 274 additions and 32 deletions

View File

@ -288,6 +288,29 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
emit CallManage::getInstance()->sig_changeDepth(m_strUuid, m_strSlfName, m_strWellName, m_iY1, m_iY2);
}
}
//曲线---------------------------
else if("显示名称" == m_propertyData[pProperty])
{
//qDebug() << "显示名称->改变";
//当前属性类型
if(m_strCurrentProperty == Curve_Property)
{
QString newAliasName = variant.value<QString>();
m_formInfo->m_strAliasName = newAliasName;
m_formInfo->update();
}
}
else if("显示单位" == m_propertyData[pProperty])
{
//qDebug() << "显示单位->改变";
//当前属性类型
if(m_strCurrentProperty == Curve_Property)
{
QString newUnit = variant.value<QString>();
m_formInfo->m_strUnit = newUnit;
m_formInfo->update();
}
}
else if("左刻度" == m_propertyData[pProperty])
{
//qDebug() << "左刻度->改变";
@ -1010,6 +1033,7 @@ void PropertyWidget::initCurveProperty(FormInfo *formInfo, QStringList strListOt
//初始化,清空
InitCurrentViewInfo();
m_strUuid = formInfo->m_strUuid;
m_formInfo = formInfo;
//
m_strSlfName = formInfo->m_strSlfName;

View File

@ -56,8 +56,8 @@ FormDraw::FormDraw(QWidget *parent, QString strWellName, QString strTrackName) :
m_nSltk=15.0;//杆状图长度
connect(CallManage::getInstance(), SIGNAL(sig_AddLine(QString, QString, QString, QString, QString)), this, SLOT(s_addLine(QString, QString, QString, QString, QString)));
connect(CallManage::getInstance(), SIGNAL(sig_AddLine_Property(QString, QString, QString, QString, QString, double, double, QString, QColor, double, Qt::PenStyle)),
this, SLOT(s_AddLine_Property(QString, QString, QString, QString, QString, double, double, QString, QColor, double, Qt::PenStyle)));
connect(CallManage::getInstance(), SIGNAL(sig_AddLine_Property(QString, QString, QString, QString, QString, double, double, QString, QColor, double, Qt::PenStyle, QStringList)),
this, SLOT(s_AddLine_Property(QString, QString, QString, QString, QString, double, double, QString, QColor, double, Qt::PenStyle, QStringList)));
connect(CallManage::getInstance(), SIGNAL(sig_delLine(QString, QString, QString, QString)), this, SLOT(s_delLine(QString, QString, QString, QString)));
connect(CallManage::getInstance(), SIGNAL(sig_MouseMove(QString, QString, QString, float)), this, SLOT(s_MouseMove(QString, QString, QString, float)));
//波列
@ -291,6 +291,8 @@ void FormDraw::DisplayLine_One(QJsonObject lineObjInfo)
QString strWellName = "";
// QString strTrackName = "";
QString strLineName = "";
QString strAliasName = "";//显示名称
QString strUnit = "";//单位
//
double newLeftScale = 0;//左刻度
double newRightScale = 500;//右刻度
@ -354,6 +356,22 @@ void FormDraw::DisplayLine_One(QJsonObject lineObjInfo)
//qDebug() << "LineName:" << strLineName;
}
}
if (lineObjInfo.contains("AliasName"))
{
QJsonValue value = lineObjInfo.value("AliasName");
if (value.isString()) {
strAliasName = value.toString();
//qDebug() << "strAliasName:" << strAliasName;
}
}
if (lineObjInfo.contains("Unit"))
{
QJsonValue value = lineObjInfo.value("Unit");
if (value.isString()) {
strUnit = value.toString();
//qDebug() << "strUnit:" << strUnit;
}
}
if (lineObjInfo.contains("vmin"))
{
@ -408,9 +426,12 @@ void FormDraw::DisplayLine_One(QJsonObject lineObjInfo)
if (strLineName != "")
{
QStringList listOtherProperty;
listOtherProperty.append(strAliasName);
listOtherProperty.append(strUnit);
//新建曲线
s_AddLine_Property(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName,
newLeftScale, newRightScale, strScaleType, lineColor, width, lineStyle);
newLeftScale, newRightScale, strScaleType, lineColor, width, lineStyle, listOtherProperty);
}
//---------------
@ -605,7 +626,7 @@ void FormDraw::s_addLine(QString strUuid, QString strSlfName, QString strWellNam
}
void FormDraw::s_AddLine_Property(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName,
double newLeftScale, double newRightScale, QString strScaleType, QColor lineColor, double width, Qt::PenStyle lineStyle)
double newLeftScale, double newRightScale, QString strScaleType, QColor lineColor, double width, Qt::PenStyle lineStyle, QStringList listOtherProperty)
{
//井名&道名不一致
if(strUuid == m_strUuid && m_strWellName == strWellName && m_strTrackName == strTrackName)
@ -660,7 +681,7 @@ AppendConsole(PAI_INFO, "FormDraw s_AddLine_Property");
curv->show();
initForm(curv, strSlfName, strLineName,
newLeftScale, newRightScale, strScaleType, lineColor, width, lineStyle);
newLeftScale, newRightScale, strScaleType, lineColor, width, lineStyle, listOtherProperty);
connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*)));
@ -2277,7 +2298,7 @@ void FormDraw::s_addTubingstring(QString strUuid, QString strSlfName, QString st
}
void FormDraw::initForm(QMyCustomPlot *widget, QString strSlfName, QString strLineName,
double newLeftScale, double newRightScale, QString strScaleType, QColor lineColor, double width, Qt::PenStyle lineStyle)
double newLeftScale, double newRightScale, QString strScaleType, QColor lineColor, double width, Qt::PenStyle lineStyle, QStringList listOtherProperty)
{
//AppendConsole(PAI_INFO, "FormDraw initForm");
@ -2309,10 +2330,19 @@ void FormDraw::initForm(QMyCustomPlot *widget, QString strSlfName, QString strLi
QString strAliasName="";
QString strUnit="";
bool bFind = getAliasNameFromIni(strLineName, strAliasName, strUnit);//曲线别名
if(!bFind)
if(listOtherProperty.size()>=2)
{
strAliasName=strLineName;
strAliasName=listOtherProperty[0];
strUnit=listOtherProperty[1];
}
else
{
bool bFind = getAliasNameFromIni(strLineName, strAliasName, strUnit);//曲线别名
if(!bFind)
{
strAliasName=strLineName;
}
}
//最大值,最小值

View File

@ -96,7 +96,7 @@ public:
public:
void initForm(QMyCustomPlot *widget, QString strSlfName, QString strLineName,
double newLeftScale=-9999, double newRightScale=-9999, QString strScaleType="线性", QColor lineColor=QColor(0,0,0), double width=1, Qt::PenStyle lineStyle=Qt::SolidLine);
double newLeftScale=-9999, double newRightScale=-9999, QString strScaleType="线性", QColor lineColor=QColor(0,0,0), double width=1, Qt::PenStyle lineStyle=Qt::SolidLine, QStringList listOtherProperty={});
void addRandomGraph(QMyCustomPlot *widget, QVector<double> x, QVector<double> y, QString strSlfName, QString strLineName, QString strAliasName, QString strUnit,
double newLeftScale=-9999, double newRightScale=-9999, QString strScaleType="线性", QColor lineColor=QColor(0,0,0), double width=1, Qt::PenStyle lineStyle=Qt::SolidLine);
void setupLineStyleDemo(QMyCustomPlot *customPlot);
@ -213,7 +213,7 @@ signals:
public slots:
void s_addLine(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName);
void s_AddLine_Property(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName,
double newLeftScale, double newRightScale, QString strScaleType, QColor lineColor, double width, Qt::PenStyle lineStyle);//新建曲线,带属性
double newLeftScale, double newRightScale, QString strScaleType, QColor lineColor, double width, Qt::PenStyle lineStyle, QStringList listOtherProperty);//新建曲线,带属性
void s_delLine(QString strUuid, QString strWellName, QString strTrackName, QString strLineName);
void s_MouseMove(QString strUuid, QString strWellName, QString strTrackName, float dep);

View File

@ -63,15 +63,17 @@ FormHead::FormHead(QWidget *parent, QString indexID) :
//我们让一列也可以滑动
// ui->tableWidget->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
// ui->tableWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
// 设置右键菜单策略
ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
// 在窗口构造函数中
//ui->tableWidget->installEventFilter(this);
// 设置整个表格的委托,或者特定列的委托
//ui->tableWidget->setItemDelegate(new BackgroundDelegate(ui->tableWidget));
// 设置右键菜单策略
ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
// 连接信号和槽
connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenu(QPoint)));
//connect(ui->tableWidget, SIGNAL(itemClicked(QTableWidgetItem*)), this, SLOT(slotItemClicked(QTableWidgetItem*)));
}

View File

@ -6,6 +6,7 @@
#include <QMimeData>
#include <QPushButton>
#include <QVBoxLayout>
#include <QMenu>
#include "geometryutils.h"
#include "qtColorSchemeComboBox.h"
@ -361,7 +362,7 @@ void FormInfo::paintEvent(QPaintEvent* event)
if(m_strType=="curveObject")
{
//曲线
painter.drawText(rect.left(), rect.top()+rect.height()/3, rect.width(), rect.height()/3, Qt::AlignCenter, m_strUnit);
//painter.drawText(rect.left(), rect.top()+rect.height()/3, rect.width(), rect.height()/3, Qt::AlignCenter, m_strUnit);
}
//---------------
if(m_strLineName=="WORDS_RELUST")
@ -840,4 +841,26 @@ void FormInfo::s_ChangeFillMode(QString strUuid, QString strSlfName, QString str
}
}
void FormInfo::contextMenuEvent(QContextMenuEvent *event)
{
//曲线
if(m_strType=="curveObject")
{
QMenu menu(this);
menu.addAction(QIcon(::GetImagePath() + "icon/Sheet.png"), "数据对象查看", this, &FormInfo::onShowCurve);
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "删除当前对象", this, &FormInfo::onDeleteObject);
menu.exec(event->globalPos());
}
}
//数据查看
void FormInfo::onShowCurve()
{
emit CallManage::getInstance()->sig_ShowCurve(m_strSlfName, m_strLineName);
}
void FormInfo::onDeleteObject()
{
//删除曲线
emit CallManage::getInstance()->sig_delLine(m_strUuid, m_strWellName, m_strTrackName, m_strLineName);
}

View File

@ -141,23 +141,19 @@ public:
QJsonObject makeJson();
//public:
// void mousePressEvent(QMouseEvent *event) override {
// if (event->button() == Qt::LeftButton) {
// startPosition = event->globalPos() - frameGeometry().topLeft();
// event->accept();
// }
// }
//右键菜单响应函数
virtual void contextMenuEvent(QContextMenuEvent *event);
// void mouseMoveEvent(QMouseEvent *event) override {
// if (event->buttons() & Qt::LeftButton) {
// move(event->globalPos() - startPosition);
// event->accept();
// }
// }
private:
QPoint startPosition;
public slots:
//数据查看
void onShowCurve();
//删除当前对象
void onDeleteObject();
};

View File

@ -47,6 +47,8 @@ FormTrack::FormTrack(QWidget *parent, QString strWellName, QString strTrackName)
//曲线
connect(this, SIGNAL(sig_AddLine(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)),
this, SLOT(s_addLine(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)));
//删除曲线
connect(CallManage::getInstance(), SIGNAL(sig_delLine(QString, QString, QString, QString)), this, SLOT(s_delLine(QString, QString, QString, QString)));
//波列
connect(this, SIGNAL(sig_AddWave(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)),
this, SLOT(s_addWave(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)));
@ -342,6 +344,38 @@ void FormTrack::s_addLine(QString strSlfName, QString strWellName, QString strTr
// ui->tableWidget->setItem(row, 0, item);
}
void FormTrack::s_delLine(QString strUuid, QString strWellName, QString strTrackName, QString strLineName)
{
//井名&道名不一致
if(strUuid == m_strUuid && m_strWellName == strWellName && m_strTrackName == strTrackName)
{
}
else
{
return;
}
//
int rowCount = ui->tableWidget->rowCount();
for(int i=0; i<rowCount; i++)
{
if( ui->tableWidget->cellWidget(i, 0) != nullptr )
{
auto myWidget = ui->tableWidget->cellWidget(i, 0);
FormInfo *formInfo = qobject_cast<FormInfo*>(myWidget);//获得widget
if(formInfo)
{
if(strUuid == formInfo->m_strUuid
&& formInfo->m_strWellName == strWellName
&& formInfo->m_strTrackName == strTrackName
&& formInfo->m_strLineName == strLineName)
{
ui->tableWidget->removeRow(i);
}
}
}
}
}
void FormTrack::s_addWave(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType)
{
qDebug() << "FormTrack s_addWave";

View File

@ -88,6 +88,7 @@ signals:
public slots:
void s_addLine(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
void s_delLine(QString strUuid, QString strWellName, QString strTrackName, QString strLineName);
void s_addWave(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
void s_AddTableLine(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);

View File

@ -2,6 +2,8 @@
#include "ui_formwell.h"
#include "CallManage.h"
#include "qtColorSchemeComboBox.h"
#include "geometryutils.h"
#include "mainwindowcurve.h"
extern int g_iOneWidth; //道宽
//extern int m_iY1;
@ -15,7 +17,7 @@ FormWell::FormWell(QWidget *parent, QString strWellName) :
ui(new Ui::FormWell)
{
ui->setupUi(this);
m_parent = parent;
m_strWellName = strWellName;
//
@ -26,6 +28,11 @@ FormWell::FormWell(QWidget *parent, QString strWellName) :
//ui->tableWidget->verticalHeader()->setFixedWidth(3);//标题栏宽度
ui->tableWidget->horizontalHeader()->setFixedHeight(3);
// 设置右键菜单策略
ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
// 连接信号和槽
connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenu(QPoint)));
//关联信号槽
connect(CallManage::getInstance(), SIGNAL(sig_NewTrack(QString, QString, QString, QString, QString,int)), this, SLOT(s_NewTrack(QString, QString, QString, QString, QString,int)));
//关联信号槽
@ -516,3 +523,78 @@ QStringList FormWell::getLineList(QString strWellName, QString strTrackName)
return listLine;
}
void FormWell::slotContextMenu(QPoint pos)
{
//
int columnCount = ui->tableWidget->columnCount();//总列数
if(columnCount<1)
{
return;
}
//当前列
int iCurrentCol = ui->tableWidget->currentColumn();
if(iCurrentCol < 0)
{
return;
}
//当前行
int iCurrentRow = ui->tableWidget->currentRow();
if(iCurrentRow == 0)
{
QMenu menu(ui->tableWidget);
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "删除选中道", this, &FormWell::slotDeleteSelectTrack);
menu.exec(ui->tableWidget->mapToGlobal(pos));
}
}
void FormWell::slotDeleteSelectTrack()
{
//当前列
int iCurrentCol = ui->tableWidget->currentColumn();
if(iCurrentCol < 0)
{
return;
}
//当前行
int iCurrentRow = ui->tableWidget->currentRow();
if(iCurrentRow == 0)
{
ui->tableWidget->removeColumn(iCurrentCol);
resizeWindow();
}
}
void FormWell::resizeWindow()
{
QRect rect = this->rect();
int tempWidth = 0;
int tempHight = 0;
for(int i=0; i<ui->tableWidget->columnCount(); i++)
{
tempWidth += ui->tableWidget->columnWidth(i);
tempWidth += 1;
}
//
for(int j=0; j<ui->tableWidget->rowCount(); j++)
{
tempHight += ui->tableWidget->rowHeight(j);
tempHight += 1;
}
//调整大小
if(rect.width()>tempWidth)
{
ui->tableWidget->setGeometry((rect.width()-tempWidth)/2, 2, tempWidth, tempHight);
}
else
{
ui->tableWidget->setGeometry(0, 2, tempWidth, tempHight);
}
// m_parent = parent;
MainWindowCurve *parent = (MainWindowCurve *)m_parent;
parent->resizeItem(m_strWellName, tempWidth, tempHight);
}

View File

@ -35,6 +35,7 @@ public:
int m_iScale=200;
double m_iY1=0;
double m_iY2=0;
QWidget *m_parent;
public:
QJsonObject makeJson();
@ -54,6 +55,12 @@ public slots:
void slot_NewTrack_No_Line(QString strUuid, QJsonObject topObj, QJsonObject infoObj);
void s_Raise(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int iTableType, QString strFormInfoType);
//图头右键菜单响应函数
void slotContextMenu(QPoint pos);
void slotDeleteSelectTrack();
void resizeWindow();
};
#endif // FORMWELL_H

View File

@ -3218,7 +3218,7 @@ void MainWindowCurve::s_NewTrack_No_Line(QJsonObject topObj, QJsonObject infoObj
//新建曲线,带属性
void MainWindowCurve::s_AddLine_Property(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName,
double newLeftScale, double newRightScale, QString strScaleType, QColor lineColor, double width, Qt::PenStyle lineStyle)
double newLeftScale, double newRightScale, QString strScaleType, QColor lineColor, double width, Qt::PenStyle lineStyle, QStringList listOtherProperty)
{
emit CallManage::getInstance()->sig_AddLine_Property(m_strUuid, strSlfName, strWellName, strTrackName, strLineName,
newLeftScale, newRightScale, strScaleType, lineColor, width, lineStyle);
@ -3967,6 +3967,8 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo, QString strTrackN
QString strWellName = "";
// QString strTrackName = "";
QString strLineName = "";
QString strAliasName = "";//显示名称
QString strUnit = "";//单位
//
double newLeftScale = 0;//左刻度
double newRightScale = 500;//右刻度
@ -4030,6 +4032,22 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo, QString strTrackN
//qDebug() << "LineName:" << strLineName;
}
}
if (lineObjInfo.contains("AliasName"))
{
QJsonValue value = lineObjInfo.value("AliasName");
if (value.isString()) {
strAliasName = value.toString();
//qDebug() << "strAliasName:" << strAliasName;
}
}
if (lineObjInfo.contains("Unit"))
{
QJsonValue value = lineObjInfo.value("Unit");
if (value.isString()) {
strUnit = value.toString();
//qDebug() << "strUnit:" << strUnit;
}
}
if (lineObjInfo.contains("vmin"))
{
@ -4084,9 +4102,12 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo, QString strTrackN
if(strLineName!="")
{
QStringList listOtherProperty;
listOtherProperty.append(strAliasName);
listOtherProperty.append(strUnit);
//新建曲线
s_AddLine_Property(strSlfName, strWellName, strTrackName, strLineName,
newLeftScale, newRightScale, strScaleType, lineColor, width, lineStyle);
newLeftScale, newRightScale, strScaleType, lineColor, width, lineStyle, listOtherProperty);
}
//---------------
@ -4196,3 +4217,25 @@ void MainWindowCurve::DisplayType_One(QJsonObject lineObjInfo, QString strTrackN
//新建道
emit CallManage::getInstance()->sig_NewCol(dt);
}
void MainWindowCurve::resizeItem(QString strWellName, double colWidth, double rowHight)
{
int column = ui->tableWidget_2->columnCount();
for(int i=0; i<column; i++)
{
if(i%2==0)
{
}
else
{
//空白列
continue;
}
//
QString strWellNameTemp = ui->tableWidget_2->item(0, i)->text();
if(strWellNameTemp==strWellName)
{
ui->tableWidget_2->setColumnWidth(i, colWidth+8);
}
}
}

View File

@ -40,7 +40,7 @@ private:
protected:
public:
void resizeItem(QString strWellName, double tempWidth, double tempHight);
public slots:
void dragEnterEvent(QDragEnterEvent* event);
@ -164,7 +164,7 @@ public slots:
void s_NewTrack_No_Line(QJsonObject topObj, QJsonObject infoObj);//新建空白道,没有曲线
void s_AddLine_Property(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName,
double newLeftScale, double newRightScale, QString strScaleType, QColor lineColor, double width, Qt::PenStyle lineStyle);//新建曲线,带属性
double newLeftScale, double newRightScale, QString strScaleType, QColor lineColor, double width, Qt::PenStyle lineStyle, QStringList listOtherProperty);//新建曲线,带属性
void s_NewTrack(); // 新建道
void s_NewDepth(); // 深度