添加深度属性,根据井的属性深度Y轴显示数值

qcustomplot, Y轴最小与最大TickLabel显示坐标修改
This commit is contained in:
DESKTOP-450PEFP\mainc 2025-12-12 20:10:30 +08:00
parent 3180ad415d
commit 8dda618fd1
16 changed files with 251 additions and 18 deletions

View File

@ -41,13 +41,15 @@ signals:
void sig_ShowTable(QString strSlfName, QString strName);//表格数据查看
void sig_WelllogInformation(QString strSlfName, QString strName);//编辑测井信息
void sig_NewTrack(QString strUuid, QString strWellName, QString strSlfName, QString strLineName, QString strType);//新建道
void sig_NewTrack(QString strUuid, QString strWellName, QString strSlfName, QString strLineName, QString strType, int nW = 0);//新建道
void sig_NewTrack_No_Line(QString strUuid, QString strWellName, QString strTrackName);//新建空白道,没有曲线
void sig_AddLine(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName);//新建曲线
void sig_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);//新建曲线,带属性
void sig_delLine(QString strUuid, QString strWellName, QString strTrackName, QString strLineName);//删除曲线
void sig_AddDepth(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW = 0);//深度
//新建波列
void sig_AddWave(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strWaveName);
//删除波列

View File

@ -10177,7 +10177,16 @@ void QCPAxisPainterPrivate::draw(QCPPainter *painter)
distanceToAxis = -(qMax(tickLengthIn, subTickLengthIn) + tickLabelPadding);
}
for (int i = 0; i < maxLabelIndex; ++i) {
placeTickLabel(painter, tickPositions.at(i), distanceToAxis, tickLabels.at(i), &tickLabelsSize);
double dpos = tickPositions.at(i);
if(i == 0)
{
dpos -= 15;
}
else if(i == maxLabelIndex-1)
{
dpos += 10;
}
placeTickLabel(painter, dpos, distanceToAxis, tickLabels.at(i), &tickLabelsSize);
}
if (tickLabelSide == QCPAxis::lsOutside) {
margin += (QCPAxis::orientation(type) == Qt::Horizontal) ? tickLabelsSize.height() : tickLabelsSize.width();

View File

@ -459,6 +459,10 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
m_item->setFont(newFont);
}
}
else if("间隔" == m_propertyData[pProperty])
{
}
}
void PropertyWidget::ChangHeadItemProperty()
@ -903,3 +907,23 @@ void PropertyWidget::initHeadProperty(FormHead *formHead, QTableWidget *tableWid
}
void PropertyWidget::initDepthProperty(FormInfo *formInfo)
{
//初始化,清空
InitCurrentViewInfo();
m_strUuid = formInfo->m_strUuid;
//
m_strSlfName = formInfo->m_strSlfName;
m_strWellName = formInfo->m_strWellName;
m_strTrackName = formInfo->m_strTrackName;
m_strLineName = formInfo->m_strLineName;
//
_CreateVariantPropertyItem("通常", "显示名称", formInfo->m_strAliasName, QVariant::String);
//
_CreateVariantPropertyItem("深度标注", "间隔", formInfo->m_nJg, QVariant::String);
}

View File

@ -86,6 +86,8 @@ public:
//图头
void initHeadProperty(FormHead *formHead, QTableWidget *tableWidget, QTableWidgetItem* item, int row, int col);
void initDepthProperty(FormInfo *formInfo);
void ChangFillProperty();//填充属性改变
void ChangHeadItemProperty();//图头项改变

View File

@ -56,6 +56,8 @@ FormDraw::FormDraw(QWidget *parent, QString strWellName, QString strTrackName) :
connect(CallManage::getInstance(), SIGNAL(sig_AddTableLine(QString, QString, QString, QString, QString)), this, SLOT(s_addTableLine(QString, QString, QString, QString, QString)));
connect(CallManage::getInstance(), SIGNAL(sig_delTableLine(QString, QString, QString, QString)), this, SLOT(s_delTableLine(QString, QString, QString, QString)));
connect(CallManage::getInstance(), SIGNAL(sig_AddDepth(QString, QString, QString, QString, QString, int)), this, SLOT(s_addDepth(QString, QString, QString, QString, QString,int)));
}
FormDraw::~FormDraw()
@ -739,6 +741,80 @@ void FormDraw::s_selectionRectAccepted(const QRect &rect, QMouseEvent *event)
// double y2 = widget->yAxis->pixelToCoord(rect.bottom());
}
void FormDraw::s_addDepth(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW)
{
//井名&道名不一致
if(strUuid == m_strUuid && m_strWellName == strWellName && m_strTrackName == strTrackName)
{
}
else
{
return;
}
if(m_listLineName.contains(strLineName))
{
qDebug() << "FormDraw strLineName already exist! " << strLineName;
return;
}
//
QMyCustomPlot *curv = new QMyCustomPlot(this, strSlfName, strWellName, strTrackName, strLineName);
curv->m_strUuid = m_strUuid;
//背景设置成透明色
curv->setBackground(Qt::transparent);
curv->setStyleSheet("background: transparent;");
//
//QRect rect = this->rect();
//curv->setGeometry(rect.left(),rect.top(), rect.width(), rect.height());
curv->yAxis->setTickLabels(true);
curv->yAxis->setTickLabelSide(QCPAxis::lsInside);
QFont font1("微软雅黑", 16); //fontSize 10
curv->yAxis->setTickLabelFont(font1);
curv->yAxis->setRange(g_iY1, g_iY2);
curv->axisRect()->setupFullAxesBox();
//
// curv->xAxis->ticker()->setTickCount(10);//x个主刻度
// curv->yAxis->ticker()->setTickCount(60);//y个主刻度
//对调XY轴在最前面设置
QCPAxis *yAxis = curv->yAxis;
QCPAxis *xAxis = curv->xAxis;
curv->xAxis = yAxis;
curv->yAxis = xAxis;
double dHight = 0;
dHight = (g_iY2-g_iY1)*100.0/(double)g_iScale * g_dPixelPerCm;
if(g_iShow==1)
{
//显示刻度
dHight = dHight+30;
}
qDebug() << "FormDraw dHight=" << QString::number((int)dHight);
if(dHight>32767)
{
dHight = 32767;
}
//curv->setMaximumHeight((int)dHight);
//curv->setViewport(QRect(0, 0, g_iOneWidth, (int)dHight));//7500-3184
curv->setGeometry(0, 0, nW, (int)dHight);//7500-3184
curv->show();
connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*)));
QString strAliasName = "深度";
QString strUnit = "";
QColor newlineColor=QColor(0,0,0);
double width=2;
QString strScaleType = "";
//道-对象
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_vmax, m_vmin, strScaleType, "depthObject");
//
m_listLineName.push_back(strLineName);
}
void FormDraw::initForm(QMyCustomPlot *widget, QString strSlfName, QString strLineName,
double newLeftScale, double newRightScale, QString strScaleType, QColor lineColor, double width, Qt::PenStyle lineStyle)
{

View File

@ -156,6 +156,8 @@ public slots:
void s_handleRectRangeChange(QCPRange newRange);
void s_selectionRectAccepted(const QRect &rect, QMouseEvent *event);
void s_addDepth(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW);
//
void s_addWave(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strWaveName);
void s_delWave(QString strUuid, QString strWellName, QString strTrackName, QString strLineName);

View File

@ -220,8 +220,11 @@ void FormInfo::paintEvent(QPaintEvent* event)
//文字结论,不绘制左右范围
}
else {
if(m_strType!="depthObject")
{
painter.drawText(rect.left(), rect.top()+rect.height()*2/3, rect.width(), rect.height()/3 ,Qt::AlignCenter, QString::number(m_vmin)+" ~ "+QString::number(m_vmax));
}
}
QWidget::paintEvent(event);
}

View File

@ -86,6 +86,8 @@ public:
QColor m_frontColor;//岩性前景色
QColor m_backColor;//岩性背景色
int m_nJg;
public:
void setLineWidth(double dWidth);
double getLineWidth();

View File

@ -52,6 +52,10 @@ FormTrack::FormTrack(QWidget *parent, QString strWellName, QString strTrackName)
connect(this, SIGNAL(sig_AddTableLine(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)),
this, SLOT(s_AddTableLine(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)));
// 深度
connect(this, SIGNAL(sig_AddDepth(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)),
this, SLOT(s_addDepth(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)));
//曲线选中,置顶
connect(CallManage::getInstance(), SIGNAL(sig_Raise(QString, QString, QString, QString, QString)), this, SLOT(s_Raise(QString, QString, QString, QString, QString)));
@ -93,6 +97,10 @@ void FormTrack::Add(QString strSlfName, QString strWellName, QString strTrackNam
//新建表格曲线
emit sig_AddTableLine(strSlfName, strWellName, m_strTrackName, strLineName, strAliasName, strUnit, lineColor, dWidth, vmax, vmin, strScaleType);
}
else if(strType=="depthObject")
{
emit sig_AddDepth(strSlfName, strWellName, m_strTrackName, strLineName, strAliasName, strUnit, lineColor, dWidth, vmax, vmin, strScaleType);
}
}
void FormTrack::s_addLine(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType)
@ -236,6 +244,39 @@ void FormTrack::s_AddTableLine(QString strSlfName, QString strWellName, QString
// ui->tableWidget->setItem(row, 0, item);
}
void FormTrack::s_addDepth(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_addDepth";
ui->tableWidget->m_strUuid = m_strUuid;
int row = ui->tableWidget->rowCount();
ui->tableWidget->setRowCount(row + 1);
//避免出现小滚动条
//ui->tableWidget->resize(g_iOneWidth, 100*(row + 1)+10);
//this->resize(g_iOneWidth, 100*(row + 1)+30);
//曲线信息栏
FormInfo *formInfo = new FormInfo(this, strSlfName, strWellName, strTrackName, strLineName, lineColor);
formInfo->m_strUuid = m_strUuid;
formInfo->m_strAliasName = strAliasName;
formInfo->m_strUnit = strUnit;
formInfo->m_strScaleType = strScaleType;
formInfo->m_strType = "depthObject";
formInfo->m_nJg = 2;
formInfo->setLineWidth(dWidth);
formInfo->setVMax(vmax);
formInfo->setVMin(vmin);
formInfo->setFrontColor(QColor(0,0,0));
formInfo->setBackColor(QColor(255,255,255));
//设置高度
ui->tableWidget->setRowHeight(row, 100);
//单元格委托
//ui->tableWidget->setItemDelegateForRow(row, m_delegate);
//
ui->tableWidget->setCellWidget(row, 0, formInfo);
}
QJsonObject FormTrack::makeJson()
{
// 创建根对象

View File

@ -69,11 +69,15 @@ signals:
void sig_AddWave(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
void sig_AddTableLine(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
void sig_AddDepth(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
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_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);
void s_addDepth(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
void s_Raise(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName);
};

View File

@ -26,7 +26,7 @@ FormWell::FormWell(QWidget *parent, QString strWellName) :
ui->tableWidget->horizontalHeader()->setFixedHeight(3);
//关联信号槽
connect(CallManage::getInstance(), SIGNAL(sig_NewTrack(QString, QString, QString, QString, QString)), this, SLOT(s_NewTrack(QString, QString, QString, QString, QString)));
connect(CallManage::getInstance(), SIGNAL(sig_NewTrack(QString, QString, QString, QString, QString,int)), this, SLOT(s_NewTrack(QString, QString, QString, QString, QString,int)));
//关联信号槽
connect(CallManage::getInstance(), SIGNAL(sig_NewTrack_No_Line(QString, QString, QString)), this, SLOT(s_NewTrack_No_Line(QString, QString, QString)));
@ -46,7 +46,7 @@ void FormWell::s_Raise(QString strUuid, QString strSlfName, QString strWellName,
ui->tableWidget->clearSelection();
}
void FormWell::s_NewTrack(QString strUuid, QString strWellName, QString strSlfName, QString strLineName, QString strType)
void FormWell::s_NewTrack(QString strUuid, QString strWellName, QString strSlfName, QString strLineName, QString strType,int nW)
{
//判断当前井是否与自己同名
if(strUuid != m_strUuid || strWellName != m_strWellName)
@ -54,16 +54,22 @@ void FormWell::s_NewTrack(QString strUuid, QString strWellName, QString strSlfNa
return;
}
if(nW <= 0)
nW = g_iOneWidth;
//因为tableWidget需要提前规定好行数与列数
int rowcount = 3; //总行数
int columnCount = ui->tableWidget->columnCount();//总列数
//增加1列
ui->tableWidget->setColumnCount(columnCount+1);
//设置列宽
ui->tableWidget->setColumnWidth(columnCount, g_iOneWidth);
ui->tableWidget->setColumnWidth(columnCount, nW);
//道名
QString strTrackName = "" + QString::number(columnCount+1);
if(strType == "depthObject")
strTrackName = "深度";
//标题
QTableWidgetItem *headerItem = new QTableWidgetItem("");
ui->tableWidget->setHorizontalHeaderItem(columnCount, headerItem);
@ -135,6 +141,12 @@ void FormWell::s_NewTrack(QString strUuid, QString strWellName, QString strSlfNa
//新建表格曲线
emit CallManage::getInstance()->sig_AddTableLine(m_strUuid, strSlfName, strWellName, strTrackName, strLineName);
}
else if(strType=="depthObject")
{
qDebug() << "新建深度";
//新建曲线
emit CallManage::getInstance()->sig_AddDepth(m_strUuid, strSlfName, strWellName, strTrackName, strLineName, nW);
}
}
//ui->tableWidget->resizeColumnsToContents(); // 调整列宽以适应内容

View File

@ -31,7 +31,7 @@ public:
void setRowHeight(double dHight, QProgressBar *progressBar, int iSplit);
public slots:
void s_NewTrack(QString strUuid, QString strWellName, QString strSlfName, QString strLineName, QString strType);
void s_NewTrack(QString strUuid, QString strWellName, QString strSlfName, QString strLineName, QString strType,int nW);
//新建空白道,没有曲线
void s_NewTrack_No_Line(QString strUuid, QString strWellName, QString strTrackName);

View File

@ -226,6 +226,9 @@ void MainWindowCurve::initToolBar()
QAction* m_grepAc2 = nullptr; //
QAction* m_loadAc2 = nullptr; //加载
QAction* _depth = new QAction(QIcon(":/image/fail.png"), "", this); //深度
_depth->setToolTip("深度");
m_newAc2 = new QAction(newFileIcon, "", this);
m_openAc2 = new QAction(openFileIcon, "", this);
m_grepAc2 = new QAction(grepIcon, "", this);
@ -246,6 +249,9 @@ void MainWindowCurve::initToolBar()
//add QAction to Widget.
ui->toolBar->addAction(m_newAc2);
ui->toolBar->addAction(m_openAc2);
ui->toolBar->addAction(_depth);
ui->toolBar->addAction(m_grepAc2);
ui->toolBar->addAction(m_compileAc2);
ui->toolBar->addAction(m_runAc2);
@ -254,6 +260,8 @@ void MainWindowCurve::initToolBar()
//connect(m_newAc2, &QAction::triggered, this, &MainWindowCurve::s_NewWell);
connect(m_openAc2, &QAction::triggered, this, &MainWindowCurve::s_NewTrack);
connect(_depth, &QAction::triggered, this, &MainWindowCurve::s_NewDepth);
// connect(m_compileAc, &QAction::triggered, this, &MainWindow::s_AddOne);
// connect(m_runAc, &QAction::triggered, this, &MainWindow::s_SaveImage);
// connect(m_debugAc, &QAction::triggered, this, &MainWindow::s_DrawImg);
@ -542,6 +550,40 @@ void MainWindowCurve::s_NewTrack()
}
void MainWindowCurve::s_NewDepth()
{
if(ui->tableWidget_2->columnCount()==0)
{
return;
}
int column = ui->tableWidget_2->currentColumn();//列编号从0开始
if(column<0)
{
//当前没有选中井
return;
}
if(column%2==0)
{
}
else
{
//空白列
return;
}
QString strWellName = ui->tableWidget_2->item(0, column)->text();
int iWidth = ui->tableWidget_2->columnWidth(column);
int nW = 100;
//设置列宽
ui->tableWidget_2->setColumnWidth(column, iWidth+nW+8);
//新建道
emit CallManage::getInstance()->sig_NewTrack(m_strUuid, strWellName, "", "深度", "depthObject", nW);
}
void MainWindowCurve::s_NewTrackChangeWidth(QString strWellName)
{
qDebug() << "MainWindowCurve s_NewTrackChangeWidth";

View File

@ -102,6 +102,8 @@ public slots:
double newLeftScale, double newRightScale, QString strScaleType, QColor lineColor, double width, Qt::PenStyle lineStyle);//新建曲线,带属性
void s_NewTrack();//新建道
void s_NewDepth(); // 深度
//
void s_Save();//保存
//void s_Open(QString fileFull);//打开

View File

@ -302,6 +302,9 @@ void PreQTableWidget::mouseReleaseEvent(QMouseEvent *event)
QStringList strListOtherLine = getListLineName(formInfo->m_strLineName, listMin, listMax, strListOtherScaleType);
//PropertyService()->initCurveProperty(formInfo->m_strSlfName, formInfo->m_strWellName, formInfo->m_strTrackName, formInfo->m_strLineName, formInfo->m_lineColor, formInfo->m_dWidth, strListOtherLine);
if(formInfo->m_strType == "depthObject")
PropertyService()->initDepthProperty(formInfo);
else
PropertyService()->initCurveProperty(formInfo, strListOtherLine, listMin, listMax, strListOtherScaleType);
//曲线置顶显示,激活可选

View File

@ -442,12 +442,16 @@ void QMyCustomPlot::s_ChangeLineColor(QString strUuid, QString strSlfName, QStri
m_strTrackName == strTrackName &&
m_strLineName == strLineName)
{
QPen pen = this->graph(0)->pen();
QCPGraph* graph =this->graph(0);
if(graph)
{
QPen pen = graph->pen();
pen.setColor(lineColor);
graph(0)->setPen(pen);
graph->setPen(pen);
//
replot();
}
}
}
//属性-线宽
@ -459,12 +463,17 @@ void QMyCustomPlot::s_ChangeLineWidth(QString strUuid, QString strSlfName, QStri
m_strTrackName == strTrackName &&
m_strLineName == strLineName)
{
QPen pen = this->graph(0)->pen();
QCPGraph* graph = this->graph(0);
if(graph)
{
QPen pen = graph->pen();
pen.setWidthF(width);
graph(0)->setPen(pen);
graph->setPen(pen);
//
replot();
}
}
}
//属性-线型