跨道引起的网格绘制问题

This commit is contained in:
DESKTOP-450PEFP\mainc 2026-04-18 13:59:53 +08:00
parent 65289a6da1
commit 4278090579
7 changed files with 95 additions and 32 deletions

View File

@ -1955,7 +1955,7 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
bool bhv = false;
bool bDraw = false;
QStringList slist;
slist << "曲线名称" << "曲线单位" << "曲线刻度" << "单比例连续折返"
slist << "曲线名称" << "曲线单位" << "曲线刻度" << "左跨道个数" << "右跨道个数" << "单比例连续折返"
<< "线宽" << "颜色" << "线型"
<< "第二比例大小" << "自动计算二比例"
<< "绘制左二比例" << "左二比例连续折返" << "左二比例左刻度" << "左二比例右刻度"
@ -2069,16 +2069,16 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
//更新填充
ChangFillProperty();
}
else if ("左跨道个数" == m_propertyData[pProperty])
{
m_formInfo->m_nLeftCross = variant.toInt();
emit CallManage::getInstance()->sig_ChangeCross(m_strUuid, m_strTrackUuid);
}
else if ("右跨道个数" == m_propertyData[pProperty])
{
m_formInfo->m_nRightCross = variant.toInt();
emit CallManage::getInstance()->sig_ChangeCross(m_strUuid, m_strTrackUuid);
}
//else if ("左跨道个数" == m_propertyData[pProperty])
//{
// m_formInfo->m_nLeftCross = variant.toInt();
// emit CallManage::getInstance()->sig_ChangeCross(m_strUuid, m_strTrackUuid);
//}
//else if ("右跨道个数" == m_propertyData[pProperty])
//{
// m_formInfo->m_nRightCross = variant.toInt();
// emit CallManage::getInstance()->sig_ChangeCross(m_strUuid, m_strTrackUuid);
//}
//else if("颜色" == m_propertyData[pProperty])
//{
// //qDebug() << "颜色->改变";

View File

@ -2644,7 +2644,7 @@ void FormDraw::DisplayType_One(QJsonObject objInfo)
}
void FormDraw::crossTrackSetting()
void FormDraw::crossTrackSetting(bool bcross)
{
if (m_formTrack == NULL || m_vecCurv.size() <= 0)
return;
@ -2672,8 +2672,9 @@ void FormDraw::crossTrackSetting()
}
if (nleft == 0 && nright == 0)
if (nleft == 0 && nright == 0 && !bcross)
return;
m_nLeftDao = nleft;
for (int i = 0; i < m_vecCurv.size(); i++)
{
@ -2699,7 +2700,7 @@ void FormDraw::crossTrackSetting()
pCurvPlot->yAxis->setRange(yRange);
int nnw = (nleft + nright + 1) * nSingleW;
QRect plotRt = pCurvPlot->geometry();
plotRt.setWidth(nnw);
plotRt.setWidth(nnw-2);
pCurvPlot->setGeometry(plotRt);
pCurvPlot->replot();
}
@ -2813,7 +2814,13 @@ void FormDraw::paintEvent(QPaintEvent*)
}
// 右边框
if (m_BorderFlags & RightBorder) {
painter.drawLine(rect.topRight(), rect.bottomRight());
QPoint pt = rect.topLeft();
QPoint pt2 = rect.bottomRight();
// 此处右边界根据道宽绘制
int ntx = (m_nLeftDao*m_nTrackW * g_dPixelPerCm)+1 + m_nTrackW * g_dPixelPerCm - 2;
pt.setX(ntx);
pt2.setX(ntx);
painter.drawLine(pt, pt2);
}
painter.restore();
@ -3144,6 +3151,8 @@ void FormDraw::s_mouseWheel(QWheelEvent *event)
void FormDraw::setColWidth(int iNewWidth)
{
m_nTrackW = iNewWidth;
iNewWidth = iNewWidth * g_dPixelPerCm;
// 获取当前widget的所有子控件
const QObjectList &children = this->children();
//判断为空
@ -3167,7 +3176,8 @@ void FormDraw::setColWidth(int iNewWidth)
if(form)
{
int dHight = form->geometry().height();
form->setGeometry(0, 0, iNewWidth, (int)dHight);//7500-3184
form->initGeometry("", m_iScale, m_nTrackW);
//form->setGeometry(0, 0, iNewWidth, (int)dHight);//7500-3184
if (form->m_strLineName == "RESULT")
{
form->setConclusionProportion(0);

View File

@ -85,7 +85,7 @@ public:
void GetTvdProperty(CDrawTvd *drawTvd, QJsonObject lineObjInfo);
// 跨道设置
void crossTrackSetting();
void crossTrackSetting(bool bcross = false);
void setBorderFlags(BorderFlags flags);
// 添加绘图
@ -140,6 +140,7 @@ public:
QPen m_zhongPen;
int m_ncuGrid = 10; // 粗网格间隔
QPen m_cuPen;
int m_nLeftDao = 0; // 左边跨道个数
QMyCustomPlot *m_curv = NULL;
// 曲线列表

View File

@ -1803,6 +1803,14 @@ bool FormInfo::setInfoProperty(QString strProName, QVariant val, QString strGp)
{
this->m_fWaveHei = val.toInt();
}
else if ("左跨道个数" == strProName)
{
this->m_nLeftCross = val.toInt();
}
else if ("右跨道个数" == strProName)
{
this->m_nRightCross = val.toInt();
}
else if ("线型" == strProName)
{
if ("曲线第二比例" == strGp)

View File

@ -380,7 +380,7 @@ void FormWell::s_ChangeCross(QString strUuid, QString strTrackUuid)
return;
FormDraw *formDraw = qobject_cast<FormDraw*>(vecWgt.at(2));
if (formDraw == NULL || formDraw->m_curv == NULL)
if (formDraw == NULL)
return;
formDraw->crossTrackSetting();
@ -614,7 +614,7 @@ int FormWell::setColWidth(int iCurrentCol, float fWidth)
// pinfo->setGeometry(rt);
// }
}
formDraw->setColWidth(iNewWidth);
formDraw->setColWidth(fWidth);
}
}

View File

@ -217,7 +217,8 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel
void QMyCustomPlot::initGeometry(QString strUuid, int nscale, double fW)
{
this->m_strUuid = strUuid;
if (strUuid.length() > 0)
this->m_strUuid = strUuid;
double dHight = (m_iY2 - m_iY1)*100.0 / (double)nscale * g_dPixelPerCm;
if (g_iShow == 1)
@ -5147,6 +5148,14 @@ void QMyCustomPlot::s_changeDrawProperty(QVariantList vlist)
{
this->setShowProperty(varVal, 5);
}
else if ("左跨道个数" == strProperty)
{
m_formDraw->crossTrackSetting(true);
}
else if ("右跨道个数" == strProperty)
{
m_formDraw->crossTrackSetting(true);
}
else if ("单比例连续折返" == strProperty)
{
QCPGraph *graph = this->graph(1);
@ -5804,7 +5813,7 @@ void QMyCustomPlot::s_ChangeLeftScale(QString strUuid, QString strSlfName, QStri
m_strLineName == strLineName)
{
m_iX1 = newLeftScale;
drawGrid();
double rg = m_iX2 - m_iX1;
double lower = m_iX1 - rg * m_nLeftCross;
double upper = m_iX2 + rg * m_nRightCross;
@ -5844,7 +5853,7 @@ void QMyCustomPlot::s_ChangeRightScale(QString strUuid, QString strSlfName, QStr
m_strLineName == strLineName)
{
m_iX2 = newRightScale;
drawGrid();
double rg = m_iX2 - m_iX1;
double lower = m_iX1 - rg * m_nLeftCross;
double upper = m_iX2 + rg * m_nRightCross;
@ -10263,6 +10272,39 @@ void QMyCustomPlot::setScaleX(float fx1, float fx2)
}
}
void QMyCustomPlot::drawGrid()
{
for (int i = 0; i < m_vecColGrid.size(); i++)
{
this->removeItem(m_vecColGrid.at(i));
}
m_vecColGrid.clear();
float fx1 = m_iX1;
float fx2 = m_iX2;
float fabs1 = (fx2 - fx1) / 10.0f;
for (; fx1 < fx2; fx1 += fabs1)
{
QCPItemStraightLine* pGline = new QCPItemStraightLine(this);
pGline->setPen(QPen(QColor(208, 208, 208), 1, Qt::SolidLine));
if (this->m_bX2Y == true)
{
pGline->point1->setCoords(-1, fx1);//位置
pGline->point2->setCoords(-2, fx1);//位置
}
else
{
pGline->point1->setCoords(fx1, -1);//位置
pGline->point2->setCoords(fx1, -2);//位置
}
m_vecColGrid << pGline;
pGline->setLayer("topLayer");
}
drawRowGrid(true);
}
void QMyCustomPlot::setDepthY(float fy1, float fy2)
{
this->m_iY1 = fy1;
@ -10270,7 +10312,7 @@ void QMyCustomPlot::setDepthY(float fy1, float fy2)
this->yAxis->setRange(m_iY1, m_iY2);
if (m_bRowGridVisible)
drawGrid();
drawRowGrid();
}
void QMyCustomPlot::updateDepthY(float fy1, float fy2)
@ -10290,10 +10332,10 @@ void QMyCustomPlot::updateDepthY(float fy1, float fy2)
}
if (m_bRowGridVisible)
drawGrid(true);
drawRowGrid(true);
}
void QMyCustomPlot::drawGrid(bool b)
void QMyCustomPlot::drawRowGrid(bool b)
{
for (int i = 0; i < m_vecRowGrid.size(); i++)
{
@ -10305,7 +10347,7 @@ void QMyCustomPlot::drawGrid(bool b)
int nabs2 = abs(m_iY1);
for (; nabs1 < nabs2; nabs1 += 1)
{
QCPItemStraightLine* pGline = new QCPItemStraightLine(this);
QCPItemLine* pGline = new QCPItemLine(this);
if (nabs1 % m_ncuGrid == 0) // 粗网格
{
pGline->setPen(m_cuPen);
@ -10321,13 +10363,13 @@ void QMyCustomPlot::drawGrid(bool b)
if (this->m_bX2Y == true && b)
{
pGline->point1->setCoords(-nabs1, 1);//位置
pGline->point2->setCoords(-nabs1, 2);//位置
pGline->start->setCoords(-nabs1, m_iX1);//位置
pGline->end->setCoords(-nabs1, m_iX2);//位置
}
else
{
pGline->point1->setCoords(1, -nabs1);//位置
pGline->point2->setCoords(2, -nabs1);//位置
pGline->start->setCoords(m_iX1, -nabs1);//位置
pGline->end->setCoords(m_iX2, -nabs1);//位置
}
pGline->setLayer("topLayer");
m_vecRowGrid << pGline;

View File

@ -106,12 +106,14 @@ public:
//设置刻度, 绘制网格线
void setScaleX(float fx1, float fx2);
//改变左右刻度更新绘图
void drawGrid();
//设置深度, 绘制网格线
void setDepthY(float fy1, float fy2);
//改变深度更新绘图
void updateDepthY(float fy1, float fy2);
//绘制网格
void drawGrid(bool b = false);
void drawRowGrid(bool b = false);
void setRowGridVisible(bool bvis);
void setColGridVisible(bool bvis);
@ -236,7 +238,7 @@ public:
int m_ncuGrid = 10; // 粗网格间隔
QPen m_cuPen;
QVector<QCPItemStraightLine*> m_vecRowGrid; // 细网格
QVector<QCPItemLine*> m_vecRowGrid; // 细网格
QVector<QCPItemStraightLine*> m_vecColGrid;
// 组