添加井的网格绘制 粗网格,中网格,细网格,粗中细颜色粗细类型可编辑

This commit is contained in:
DESKTOP-450PEFP\mainc 2026-04-13 21:33:20 +08:00
parent b2ff354e10
commit 253c940112
12 changed files with 323 additions and 32 deletions

View File

@ -171,6 +171,8 @@ signals:
//改变深度
void sig_changeDepth(QString strUuid, QString strSlfName, QString strWellName, int iY1, int iY2);
void sig_changeWellProperty(QString strSlfName, QString strWellName, QVariantList listVal);
//改变道宽
void sig_changeWidth(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, int iCurrentCol, int iNewWidth);
//改变道属性

View File

@ -1906,7 +1906,14 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
}
else if(m_strCurrentProperty == Well_Property)
{
if("开始深度(m)" == m_propertyData[pProperty])
QString strGroup = "";
if (1 == pProperty->getParentItem().count())
{
QtProperty * pParentProperty = *(pProperty->getParentItem().begin());
strGroup = pParentProperty->propertyName();
}
QString strPro = m_propertyData[pProperty];
if("开始深度(m)" == strPro)
{
//qDebug() << "开始深度(m)->改变";
double newStartDepth = variant.value<double>();
@ -1918,7 +1925,7 @@ 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)" == m_propertyData[pProperty])
else if("终止深度(m)" == strPro)
{
//qDebug() << "终止深度(m)->改变";
double newEndDepth = variant.value<double>();
@ -1930,6 +1937,11 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
//通知界面
emit CallManage::getInstance()->sig_changeDepth(m_strUuid, m_strSlfName, m_strWellName, m_iY1, m_iY2);
}
else
{
QVariantList vlist = { strGroup, strPro, variant };
emit CallManage::getInstance()->sig_changeWellProperty(m_strSlfName, m_strWellName, vlist);
}
}
else if(m_strCurrentProperty == Curve_Property)
{
@ -2680,7 +2692,7 @@ void PropertyWidget::initWidgetProperty(QString strUuid, int iScale)
_CreateVariantPropertyItem("水平格线", "中格线间隔(m)", 2.0, QVariant::Double);
}
void PropertyWidget::initWellProperty(QString strUuid, QString strSlfName, QString strWellName, double iY1, double iY2)
void PropertyWidget::initWellProperty(QString strUuid, QString strSlfName, QString strWellName, double iY1, double iY2, FormWell* fWell)
{
//初始化,清空
InitCurrentViewInfo();
@ -2698,6 +2710,31 @@ void PropertyWidget::initWellProperty(QString strUuid, QString strSlfName, QStri
//
_CreateVariantPropertyItem("通常", "开始深度(m)", 0-m_iY2, QVariant::Double);
_CreateVariantPropertyItem("通常", "终止深度(m)", 0-m_iY1, QVariant::Double);
if (fWell)
{
this->initGridProperty("粗网格", QStringList({ "间隔(m)","线宽","颜色","线型" }), fWell->getCuGridProperty());
this->initGridProperty("中网格", QStringList({ "间隔(m)","线宽","颜色","线型" }), fWell->getZhongGridProperty());
this->initGridProperty("细网格", QStringList({ "间隔(m)","线宽","颜色","线型" }), fWell->getXiGridProperty());
this->initGridProperty("边框", QStringList({ "线宽","颜色","线型" }), fWell->getBorderGridProperty());
}
}
void PropertyWidget::initGridProperty(QString strGroup, QStringList slist, GridProperty& gridp)
{
if (strGroup != "边框")
_CreateVariantPropertyItem(strGroup, "间隔(m)", gridp.m_nInv, QVariant::Int);
_CreateVariantPropertyItem(strGroup, "线宽", gridp.m_nWidth, QVariant::Int);
_CreateVariantPropertyItem(strGroup, "颜色", gridp.m_clor, QVariant::Color);
QStringList listStyle;
listStyle.append("");
listStyle.append("实线");
listStyle.append("虚线");
listStyle.append("点线");
listStyle.append("虚点线");
listStyle.append("虚点点线");
_CreateEnumPropertyItem(strGroup, "线型", gridp.m_nType, listStyle);
}
void PropertyWidget::initTrackProperty(FormTrackTop *fromTop, int iWidth, QMyTableWidget *myTableWidget, int iCurrentCol)

View File

@ -18,6 +18,7 @@
//
#include "forminfo.h"
#include "formhead.h"
#include "formwell.h"
#include "qmytablewidget.h"
#include "formtracktop.h"
#include "TransparentDraggableGujing.h"
@ -165,7 +166,8 @@ public:
void InitCurrentViewInfo(bool bAll = true); //初始化属性,清空
void initWidgetProperty(QString strUuid, int iScale); //可视解释整体属性
//井
void initWellProperty(QString strUuid, QString strSlfName, QString strWellName, double iY1, double iY2);
void initWellProperty(QString strUuid, QString strSlfName, QString strWellName, double iY1, double iY2, FormWell* fWell);
void initGridProperty(QString strGroup, QStringList slist, GridProperty& gridp);
//道
void initTrackProperty(FormTrackTop *fromTop, int iWidth, QMyTableWidget *myTableWidget, int iCurrentCol);
//曲线

View File

@ -190,6 +190,8 @@ void CustomTabWidget::dropEvent(QDropEvent *event)
void CustomTabWidget::slot_tabClose(int index)
{
QWidget *selectWidget = tabWidget(index);
if (selectWidget == NULL)
return;
QString objectName = selectWidget->objectName();
if(objectName == "MainWindowSplitter")

View File

@ -146,6 +146,11 @@ void FormDraw::setDrawData(QStringList listdt, QJsonObject objInfo)
QMyCustomPlot *curv = new QMyCustomPlot(this, strSlfName, strWellName, m_strTrackName, strLineName);
//绑定m_formTrack方便关联formInfo
curv->m_formTrack = m_formTrack;
if ("depthObject" == strType)
{
curv->m_bRowGridVisible = false;
curv->m_bColGridVisible = false;
}
curv->setDepthY(m_iY1, m_iY2);
curv->initGeometry(m_strUuid, m_iScale, nW);
curv->show();
@ -2718,6 +2723,66 @@ void FormDraw::setBorderFlags(BorderFlags flags)
m_BorderFlags = flags;
}
void FormDraw::addCusPlot(QMyCustomPlot* plot)
{
m_vecCurv.push_back(plot);
}
bool FormDraw::isHvRowGridLine()
{
bool bret = false;
for (int i = 0; i < m_vecCurv.size(); i++)
{
QMyCustomPlot* plot = m_vecCurv.at(i);
bret = plot->m_bRowGridVisible;
if (bret)
{
break;
}
}
return bret;
}
void FormDraw::setGridProperty(int ncuGrid, /* 粗网格间隔 */ QPen cuPen, int nzhongGrid, /* 中网格间隔 */ QPen zhongPen, int nxiGrid, /* 细网格间隔 */ QPen xiPen)
{
m_ncuGrid = ncuGrid;
m_cuPen = cuPen;
m_nzhongGrid = nzhongGrid;
m_zhongPen = zhongPen;
m_nxiGrid = nxiGrid;
m_xiPen = xiPen;
}
void FormDraw::changeGridProperty(QString strGroup, int nInv, int nWidth, QColor clor, int nType)
{
for (int i = 0; i < m_vecCurv.size(); i++)
{
QMyCustomPlot* plot = m_vecCurv.at(i);
if (plot->m_bRowGridVisible)
{
QPen p = QPen(clor, nWidth, (Qt::PenStyle)nType);
if (strGroup == "粗网格")
{
plot->m_ncuGrid = nInv;
plot->m_cuPen = p;
}
else if (strGroup == "中网格")
{
plot->m_nzhongGrid = nInv;
plot->m_zhongPen = p;
}
else if (strGroup == "细网格")
{
plot->m_nxiGrid = nInv;
plot->m_xiPen = p;
}
plot->updateDepthY(plot->m_iY1, plot->m_iY2);
plot->replot();
break;
}
}
}
void FormDraw::paintEvent(QPaintEvent*)
{
QPainter painter(this);
@ -3165,7 +3230,7 @@ void FormDraw::setRowHeight(double dHight, QProgressBar *progressBar, int iSplit
if(form)
{
int nw = form->geometry().width();
form->setGeometry(0, 0, nw-2, (int)dHight);//7500-3184
form->setGeometry(0, 0, nw, (int)dHight);//7500-3184
form->updateDepthY(m_iY1, m_iY2);
//emit CallManage::getInstance()->sig_ChangeLeftScale(m_strUuid, form->m_strSlfName, m_strWellName, m_strTrackName, form->m_strLineName, form->m_iX1);

View File

@ -88,6 +88,20 @@ public:
void crossTrackSetting();
void setBorderFlags(BorderFlags flags);
// 添加绘图
void addCusPlot(QMyCustomPlot* plot);
// 绘图是否有显示横线格子;
bool isHvRowGridLine();
void setGridProperty(int ncuGrid, // 粗网格间隔
QPen cuPen,
int nzhongGrid, // 中网格间隔
QPen zhongPen,
int nxiGrid, // 细网格间隔
QPen xiPen);
// 更新绘图区域网格线
void changeGridProperty(QString strGroup, int nInv,
int nWidth, QColor clor, int nType);
private:
Ui::FormDraw *ui;
@ -118,6 +132,12 @@ public:
int m_iScale=200;
double m_iY1=0;
double m_iY2=0;
int m_nxiGrid = 1; // 细网格间隔
QPen m_xiPen;
int m_nzhongGrid = 2; // 中网格间隔
QPen m_zhongPen;
int m_ncuGrid = 10; // 粗网格间隔
QPen m_cuPen;
QMyCustomPlot *m_curv = NULL;
// 曲线列表

View File

@ -21,7 +21,14 @@ FormWell::FormWell(QWidget *parent, QString strWellName) :
m_parent = parent;
m_strWellName = strWellName;
//
m_cuProperty.m_nInv = 10;
m_cuProperty.m_nWidth = 2;
m_zhongProperty.m_nInv = 2;
m_zhongProperty.m_clor = QColor(103,103,103);
m_xiProperty.m_clor = QColor(208,208,208);
ui->tableWidget->verticalHeader()->hide(); //行
ui->tableWidget->horizontalHeader()->hide();//列
int rowcount = 3; //总行数
@ -232,6 +239,9 @@ QVector<QWidget *> FormWell::new_track(QStringList listdt, QString strTrackName)
vec << formDraw;
formDraw->m_iY1 = m_iY1;
formDraw->m_iY2 = m_iY2;
formDraw->setGridProperty(m_cuProperty.m_nInv, QPen(m_cuProperty.m_clor, m_cuProperty.m_nWidth, Qt::PenStyle(m_cuProperty.m_nType)),
m_zhongProperty.m_nInv, QPen(m_zhongProperty.m_clor, m_zhongProperty.m_nWidth, Qt::PenStyle(m_zhongProperty.m_nType)),
m_xiProperty.m_nInv, QPen(m_xiProperty.m_clor, m_xiProperty.m_nWidth, Qt::PenStyle(m_xiProperty.m_nType)));
formDraw->m_strUuid = m_strUuid;
formDraw->m_strSlfName = strSlfName;
formDraw->m_formTrack = formTrack;
@ -266,6 +276,26 @@ int FormWell::getTableWidgetColumn(QString strTrackUuid)
return nret;
}
GridProperty& FormWell::getCuGridProperty()
{
return m_cuProperty;
}
GridProperty& FormWell::getZhongGridProperty()
{
return m_zhongProperty;
}
GridProperty& FormWell::getXiGridProperty()
{
return m_xiProperty;
}
GridProperty& FormWell::getBorderGridProperty()
{
return m_borderProperty;
}
void FormWell::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
@ -552,6 +582,66 @@ int FormWell::setColWidth(int iCurrentCol, int iWidth)
return iWellWidth;
}
void FormWell::setWellProperty(QVariantList listVal)
{
QString strGroup = listVal.at(0).toString();
QString strPro = listVal.at(1).toString();
GridProperty* gridpt = NULL;// &pWell->getCuGridProperty();
if (strGroup == "粗网格")
{
gridpt = &m_cuProperty;
}
else if (strGroup == "中网格")
{
gridpt = &m_zhongProperty;
}
else if (strGroup == "细网格")
{
gridpt = &m_xiProperty;
}
else if (strGroup == "边框")
{
gridpt = &m_borderProperty;
}
if (gridpt == NULL)
return;
if ("间隔(m)" == strPro)
{
gridpt->m_nInv = listVal.at(2).toInt();
}
else if ("线宽" == strPro)
{
gridpt->m_nWidth = listVal.at(2).toInt();
}
else if ("颜色" == strPro)
{
QColor newColor = listVal.at(2).value<QColor>();
gridpt->m_clor = newColor;
}
else if ("线型" == strPro)
{
gridpt->m_nType = listVal.at(2).toInt();
}
int columnCount = ui->tableWidget->columnCount();//总列数
for (int i = 0; i < columnCount; i++)
{
if (ui->tableWidget->cellWidget(1, i) == nullptr)
continue;
auto myWidget = ui->tableWidget->cellWidget(2, i);
if (myWidget == nullptr)
continue;
FormDraw *formDraw = qobject_cast<FormDraw*>(myWidget);
if (formDraw)
{
formDraw->changeGridProperty(strGroup, gridpt->m_nInv, gridpt->m_nWidth, gridpt->m_clor, gridpt->m_nType);
}
}
}
void FormWell::setRowHeight(double dHight, QProgressBar *progressBar, int iSplit)
{
//设置高度

View File

@ -9,6 +9,15 @@
#pragma execution_character_set("utf-8")
struct GridProperty
{
GridProperty() :m_nInv(1), m_nWidth(1), m_clor(0, 0, 0), m_nType(1) {}
int m_nInv;
int m_nWidth;
QColor m_clor;
int m_nType;
};
namespace Ui {
class FormWell;
}
@ -30,11 +39,23 @@ public:
// 根据道ID获取列索引
int getTableWidgetColumn(QString strTrackUuid);
// 粗网格
GridProperty& getCuGridProperty();
GridProperty& getZhongGridProperty();
GridProperty& getXiGridProperty();
GridProperty& getBorderGridProperty();
protected:
void paintEvent(QPaintEvent *event);
private:
Ui::FormWell *ui;
GridProperty m_cuProperty; // 粗网格
GridProperty m_zhongProperty; // 中网格
GridProperty m_xiProperty; // 细网格
GridProperty m_borderProperty; // 边框
public:
QString m_strUuid;
QString m_strWellName;
@ -57,6 +78,8 @@ public:
//设置道宽
int setColWidth(int iCurrentCol, int iNewWidth);
void setWellProperty(QVariantList listVal);
//获取当前井的所有道名称
QStringList getTrackNameList();

View File

@ -104,6 +104,8 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) :
connect(CallManage::getInstance(), SIGNAL(sig_mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*)));
connect(CallManage::getInstance(), SIGNAL(sig_changeScale(QString, int)), this, SLOT(s_changeScale(QString, int)));
connect(CallManage::getInstance(), SIGNAL(sig_changeDepth(QString, QString, QString, int, int)), this, SLOT(s_changeDepth(QString, QString, QString, int, int)));
connect(CallManage::getInstance(), SIGNAL(sig_changeWellProperty(QString, QString, QVariantList)), this, SLOT(s_changeWellProperty(QString, QString, QVariantList)));
connect(CallManage::getInstance(), SIGNAL(sig_changeWidth(QString, QString, QString, QString, int, int)), this, SLOT(s_changeWidth(QString, QString, QString, QString, int, int)));
connect(CallManage::getInstance(), SIGNAL(sig_changeTrackProperty(QVariantList)), this, SLOT(s_changeTrackProperty(QVariantList)));
@ -2938,7 +2940,7 @@ void MainWindowCurve::s_NewWell(QString strWellName, QString strSlfName)
widgetWell->m_strSlfName = strSlfName;
widgetWell->m_iScale = m_iScale;
ui->tableWidget_2->setCellWidget(i, columnCount, widgetWell);
m_mapFWell.insert(strWellName, widgetWell);
//
m_listWell.push_back(strWellName);
}
@ -3007,8 +3009,8 @@ void MainWindowCurve::onItemClicked(QTableWidgetItem* item)
//曲线
QString strWellName = item->text();
QString strSlfName = item->data(Qt::UserRole+1).toString();
PropertyService()->initWellProperty(m_strUuid, strSlfName, strWellName, m_iY1, m_iY2);
FormWell* fWell = m_mapFWell.value(strWellName);
PropertyService()->initWellProperty(m_strUuid, strSlfName, strWellName, m_iY1, m_iY2, fWell);
//取消所有选中单元格
emit CallManage::getInstance()->sig_Raise(m_strUuid, strSlfName, strWellName, "", "", 1, "");
@ -4291,6 +4293,15 @@ void MainWindowCurve::s_changeDepth(QString strUuid, QString strSlfName, QString
//update();
}
void MainWindowCurve::s_changeWellProperty(QString strSlfName, QString strWellName, QVariantList listVal)
{
FormWell* pWell = m_mapFWell.value(strWellName);
if (!pWell)
return;
pWell->setWellProperty(listVal);
}
void MainWindowCurve::DisplayWells(QJsonArray wellsArray)
{
QMap<int, int> mapWells;

View File

@ -58,6 +58,8 @@ public:
QString m_strUuid;
QStringList m_listWell;
QMap<QString, FormWell*> m_mapFWell;
//当前选中数据表格
SelectTableItem m_SelectTableItem;
@ -145,6 +147,7 @@ public slots:
void s_changeScale(QString strUuid, int iNewScale);
//改变深度
void s_changeDepth(QString strUuid, QString strSlfName, QString strWellName, int iY1, int iY2);
void s_changeWellProperty(QString strSlfName, QString strWellName, QVariantList listVal);
//改变道宽
void s_changeWidth(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, int iCurrentCol, int iNewWidth);

View File

@ -24,6 +24,7 @@
#include "PropertyWidget.h"
#include "YxzpDialog.h"
#include "fracsel.h"
#include "formdraw.h"
//是否隐藏刻度
extern int g_iShow;
@ -41,6 +42,19 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel
m_strTrackName = strTrackName;
m_strLineName = strLineName;
FormDraw* pFormDw = qobject_cast<FormDraw*>(parent);
if (pFormDw)
{
if (pFormDw->isHvRowGridLine())
{
m_bRowGridVisible = false;
}
m_cuPen = pFormDw->m_cuPen;
m_zhongPen = pFormDw->m_zhongPen;
m_xiPen = pFormDw->m_xiPen;
pFormDw->addCusPlot(this);
}
mSizeHandleManager = new QCPSizeHandleManager(this);
setObjectName("QMyCustomPlot");
@ -9977,6 +9991,9 @@ void QMyCustomPlot::setScaleX(float fx1, float fx2)
this->m_iX2 = fx2;
this->xAxis->setRange(fx1, fx2);
if (!m_bColGridVisible)
return;
for (int i = 0; i < m_vecColGrid.size(); i++)
{
this->removeItem(m_vecColGrid.at(i));
@ -10001,26 +10018,14 @@ void QMyCustomPlot::setDepthY(float fy1, float fy2)
this->m_iY2 = fy2;
this->yAxis->setRange(m_iY1, m_iY2);
for (int i = 0; i < m_vecRowGrid.size(); i++)
{
this->removeItem(m_vecRowGrid.at(i));
}
m_vecRowGrid.clear();
int nabs1 = abs(m_iY2);
int nabs2 = abs(m_iY1);
for (; nabs1 < nabs2; nabs1 += 1)
{
QCPItemStraightLine* pGline = new QCPItemStraightLine(this);
pGline->setPen(QPen(QColor(208,208,208), 1, Qt::SolidLine));
pGline->point1->setCoords(-1, -nabs1);//位置
pGline->point2->setCoords(-2, -nabs1);//位置
m_vecRowGrid << pGline;
}
if (m_bRowGridVisible)
drawGrid();
}
void QMyCustomPlot::updateDepthY(float fy1, float fy2)
{
this->m_iY1 = fy1;
this->m_iY2 = fy2;
//深度改变
if (this->m_bX2Y == true)
{
@ -10033,26 +10038,45 @@ void QMyCustomPlot::updateDepthY(float fy1, float fy2)
this->yAxis->setRange(m_iY1, m_iY2);
}
if (m_bRowGridVisible)
drawGrid(true);
}
void QMyCustomPlot::drawGrid(bool b)
{
for (int i = 0; i < m_vecRowGrid.size(); i++)
{
this->removeItem(m_vecRowGrid.at(i));
}
m_vecRowGrid.clear();
int nabs1 = abs(m_iY2);
int nabs2 = abs(m_iY1);
for (; nabs1 < nabs2; nabs1 += 1)
{
QCPItemStraightLine* pGline = new QCPItemStraightLine(this);
pGline->setPen(QPen(QColor(208, 208, 208), 1, Qt::SolidLine));
if (this->m_bX2Y == true)
if (nabs1 % m_ncuGrid == 0) // 粗网格
{
pGline->point1->setCoords(-nabs1, -1);//位置
pGline->point2->setCoords(-nabs1, -2);//位置
pGline->setPen(m_cuPen);
}
else if (nabs1 % m_nzhongGrid == 0) // 中网格
{
pGline->setPen(m_zhongPen);
}
else if (nabs1 % m_nxiGrid == 0) // 细网格
{
pGline->setPen(m_xiPen);
}
if (this->m_bX2Y == true && b)
{
pGline->point1->setCoords(-nabs1, 1);//位置
pGline->point2->setCoords(-nabs1, 2);//位置
}
else
{
pGline->point1->setCoords(-1, -nabs1);//位置
pGline->point2->setCoords(-2, -nabs1);//位置
pGline->point1->setCoords(1, -nabs1);//位置
pGline->point2->setCoords(2, -nabs1);//位置
}
m_vecRowGrid << pGline;
}

View File

@ -95,7 +95,10 @@ public:
void setScaleX(float fx1, float fx2);
//设置深度, 绘制网格线
void setDepthY(float fy1, float fy2);
//改变深度更新绘图
void updateDepthY(float fy1, float fy2);
//绘制网格
void drawGrid(bool b = false);
protected:
@ -197,7 +200,16 @@ public:
bool m_bFirstTimeConnect=true; //初次绑定编辑曲线信号槽。
bool m_bPriviewRightList=false; //当前是否正在预览曲线。
QVector<QCPItemStraightLine*> m_vecRowGrid;
bool m_bRowGridVisible = true; // 网格横轴是否显示
bool m_bColGridVisible = true; // 网格纵轴是否显示
int m_nxiGrid = 1; // 细网格间隔
QPen m_xiPen;
int m_nzhongGrid = 2; // 中网格间隔
QPen m_zhongPen;
int m_ncuGrid = 10; // 粗网格间隔
QPen m_cuPen;
QVector<QCPItemStraightLine*> m_vecRowGrid; // 细网格
QVector<QCPItemStraightLine*> m_vecColGrid;
// 组