logplus/logPlus/formdraw.cpp

3064 lines
100 KiB
C++
Raw Normal View History

2025-10-29 17:23:30 +08:00
#include "formdraw.h"
#include "ui_formdraw.h"
#include "CallManage.h"
#include <QDebug>
#include "geometryutils.h"
#include "ConsoleOutputWidget.h"
#include "DraggablePixmap.h"
#include "TransparentDraggableRect.h"
//以下参数从配置文件读取
extern int g_iIndex;
extern int g_iNum;
extern int g_iOneWidth; //道宽
extern int g_iHeadHigh; //道头高度
extern int g_iTitleHigh; //道对象高度
extern int g_iCurveHigh;//曲线高度
extern int g_iMove; //道头偏移
extern int g_iPointNum; // number of points in graph
extern int g_iLineNum; // number of Line
extern int g_iWidth; //道宽
extern int g_iShow; //显示刻度
2025-10-29 17:23:30 +08:00
//
extern int g_iX1;
extern int g_iX2;
extern int g_iY1;
extern int g_iY2;
extern int g_iCanZoom ;
//
extern double g_dPixelPerCm;//每厘米像素数
extern int g_iScale;
extern void AppendConsole(Priority priority, const QString &output);
//曲线绘制(多个)
FormDraw::FormDraw(QWidget *parent, QString strWellName, QString strTrackName) :
QWidget(parent),
ui(new Ui::FormDraw)
{
ui->setupUi(this);
setAcceptDrops(true);
m_strWellName = strWellName;
m_strTrackName = strTrackName;
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_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)));
//波列
connect(CallManage::getInstance(), SIGNAL(sig_AddWave(QString, QString, QString, QString, QString)), this, SLOT(s_addWave(QString, QString, QString, QString, QString)));
connect(CallManage::getInstance(), SIGNAL(sig_delWave(QString, QString, QString, QString)), this, SLOT(s_delWave(QString, QString, QString, QString)));
//表格曲线
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)));
2025-10-29 17:23:30 +08:00
}
FormDraw::~FormDraw()
{
delete ui;
}
void FormDraw::paintEvent(QPaintEvent*)
{
// QPainter painter(this);
// QRect rect = this->rect();
// //背景透明
// painter.fillRect(rect.left(), rect.top(), rect.width(), rect.height(), QColor(0, 0, 0, 0)); //QColor(67, 67, 67, 100)
// painter.setPen(QPen(Qt::green,2,Qt::DashLine));
// //painter.setBrush(QBrush(Qt::red,Qt::SolidPattern));
//// QFont font1("微软雅黑", 10, false, false); //fontSize 10
//// painter.setFont(font1);
//// painter.setPen(QColor(0, 0, 0)); // fontColor QColor(220, 220, 220)
//// painter.drawText(rect.left() + 10, 10, QStringLiteral("画图")); // titleBarText QStringLiteral("动画")
// QRect rectRound(rect.left()+2,rect.top()+4, rect.width()-3, rect.height()-4);
// painter.drawRoundRect(rectRound);
}
void FormDraw::s_addLine(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName)
2025-10-29 17:23:30 +08:00
{
//井名&道名不一致
if(strUuid == m_strUuid && m_strWellName == strWellName && m_strTrackName == strTrackName)
2025-10-29 17:23:30 +08:00
{
}
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;
2025-10-29 17:23:30 +08:00
//背景设置成透明色
curv->setBackground(Qt::transparent);
curv->setStyleSheet("background: transparent;");
//
//QRect rect = this->rect();
//curv->setGeometry(rect.left(),rect.top(), rect.width(), rect.height());
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);
2025-10-29 17:23:30 +08:00
if(dHight>32767)
{
dHight = 32767;
}
//curv->setMaximumHeight((int)dHight);
//curv->setViewport(QRect(0, 0, g_iOneWidth, (int)dHight));//7500-3184
curv->setGeometry(0, 0, g_iOneWidth, (int)dHight);//7500-3184
//curv->resize(INT_MAX, INT_MAX); // 使用 INT_MAX 来避免16位整数的限制
// QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// curv->setSizePolicy(policy);
curv->show();
2025-11-05 16:45:32 +08:00
initForm(curv, strSlfName, strLineName);
connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*)));
2025-10-29 17:23:30 +08:00
//
m_listLineName.push_back(strLineName);
}
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)
2025-10-30 11:55:37 +08:00
{
//井名&道名不一致
if(strUuid == m_strUuid && m_strWellName == strWellName && m_strTrackName == strTrackName)
2025-10-30 11:55:37 +08:00
{
}
else
{
return;
}
//qDebug() << "FormDraw s_AddLine_Property";
AppendConsole(PAI_INFO, "FormDraw s_AddLine_Property");
2025-10-30 11:55:37 +08:00
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;
2025-10-30 11:55:37 +08:00
//背景设置成透明色
curv->setBackground(Qt::transparent);
curv->setStyleSheet("background: transparent;");
//
//QRect rect = this->rect();
//curv->setGeometry(rect.left(),rect.top(), rect.width(), rect.height());
double dHight = 0;
dHight = (g_iY2-g_iY1)*100.0/(double)g_iScale * g_dPixelPerCm;
if(g_iShow==1)
{
//显示刻度
dHight = dHight+30;
}
2025-10-30 11:55:37 +08:00
qDebug() << "FormDraw dHight=" << QString::number((int)dHight);
2025-10-30 11:55:37 +08:00
if(dHight>32767)
{
dHight = 32767;
}
//curv->setMaximumHeight((int)dHight);
//curv->setViewport(QRect(0, 0, g_iOneWidth, (int)dHight));//7500-3184
curv->setGeometry(0, 0, g_iOneWidth, (int)dHight);//7500-3184
//curv->resize(INT_MAX, INT_MAX); // 使用 INT_MAX 来避免16位整数的限制
// QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// curv->setSizePolicy(policy);
curv->show();
2025-10-30 11:55:37 +08:00
initForm(curv, strSlfName, strLineName,
newLeftScale, newRightScale, strScaleType, lineColor, width, lineStyle);
2025-10-30 11:55:37 +08:00
connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*)));
2025-10-30 11:55:37 +08:00
//
m_listLineName.push_back(strLineName);
AppendConsole(PAI_INFO, "FormDraw s_AddLine_Property end");
2025-10-30 11:55:37 +08:00
}
void FormDraw::s_addWave(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strWaveName)
{
//井名&道名不一致
if(strUuid == m_strUuid && m_strWellName == strWellName && m_strTrackName == strTrackName)
{
}
else
{
return;
}
if(m_listWaveName.contains(strWaveName))
{
qDebug() << "FormDraw strLineName already exist! " << strWaveName;
return;
}
//
QMyCustomPlot *curv = new QMyCustomPlot(this, strSlfName, strWellName, strTrackName, strWaveName);
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());
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, g_iOneWidth, (int)dHight);//7500-3184
//curv->resize(INT_MAX, INT_MAX); // 使用 INT_MAX 来避免16位整数的限制
// QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// curv->setSizePolicy(policy);
curv->show();
initWave(curv, strSlfName, strWaveName);
2025-12-18 17:49:23 +08:00
//initWave_3D(curv, strSlfName, strWaveName);
connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*)));
//
m_listWaveName.push_back(strWaveName);
}
2025-10-30 11:55:37 +08:00
void FormDraw::s_addTableLine(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName)
{
if(strLineName == "FRAC_HOLE.TABLE" || strLineName == "WORDS_RELUST" || strLineName == "RESULT"|| strLineName == "GEO_LITH")
{
}
else
{
return;
}
//井名&道名不一致
if(strUuid == m_strUuid && m_strWellName == strWellName && m_strTrackName == strTrackName)
{
}
else
{
return;
}
if(m_listTableName.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());
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, g_iOneWidth, (int)dHight);//7500-3184
//curv->resize(INT_MAX, INT_MAX); // 使用 INT_MAX 来避免16位整数的限制
// QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// curv->setSizePolicy(policy);
curv->show();
if(strLineName == "FRAC_HOLE.TABLE")
{
//蝌蚪图
curv->mKedou = true;
//隐藏网格
curv->xAxis->grid()->setVisible(false);
curv->yAxis->grid()->setVisible(false);
initTableLine(curv, strSlfName, strLineName);
}
else if(strLineName == "WORDS_RELUST")
{
//文字结论
initWords(curv, strSlfName, strLineName);
}
else if(strLineName == "RESULT")
{
//解释结论
initResult(curv, strSlfName, strLineName);
}
else if(strLineName == "GEO_LITH")
{
//录井剖面
initGeoLith(curv, strSlfName, strLineName);
}
connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*)));
//
m_listTableName.push_back(strLineName);
}
void FormDraw::s_mouseWheel(QWheelEvent *event)
{
emit CallManage::getInstance()->sig_mouseWheel(event);
}
void FormDraw::setRowHeight(double dHight, QProgressBar *progressBar, int iSplit)
{
int iBeginValue = progressBar->value();
// 获取当前widget的所有子控件
const QObjectList &children = this->children();
int columnCount = children.size();
int iSplitCurv = iSplit / columnCount;
int i=0;
// 遍历子控件列表
for (QObject *child : children) {
// 判断子控件是否为QWidget类型
if (QWidget *childWidget = qobject_cast<QWidget *>(child)) {
// 打印子控件的信息,使用缩进表示层级关系
//qDebug() << QString("%1").arg(childWidget->objectName());
QString strObjName = childWidget->objectName();
if(strObjName=="QMyCustomPlot")
{
//progressBar->setValue(iBeginValue+ i*iSplitCurv); // 更新进度条的值
//
QMyCustomPlot *form = (QMyCustomPlot*)childWidget;
form->setGeometry(0, 0, g_iOneWidth, (int)dHight);//7500-3184
//深度改变
form->xAxis->setRange(g_iY1, g_iY2);
//emit CallManage::getInstance()->sig_ChangeLeftScale(m_strUuid, form->m_strSlfName, m_strWellName, m_strTrackName, form->m_strLineName, form->m_iX1);
form->replot();//屏蔽,缩减时间
}
}
i++;
}
}
void FormDraw::s_delLine(QString strUuid, QString strWellName, QString strTrackName, QString strLineName)
2025-10-29 17:23:30 +08:00
{
//井名&道名不一致
if(strUuid == m_strUuid && m_strWellName == strWellName && m_strTrackName == strTrackName)
2025-10-29 17:23:30 +08:00
{
}
else
{
return;
}
qDebug() << "FormDraw s_delLine";
2025-10-29 17:23:30 +08:00
if(m_listLineName.contains(strLineName))
{
}
else
{
qDebug() << "FormDraw strLineName not exist! " << strLineName;
return;
}
//
// 获取当前widget的所有子控件
const QObjectList &children = this->children();
// 遍历子控件列表
for (QObject *child : children) {
// 判断子控件是否为QWidget类型
if (QWidget *childWidget = qobject_cast<QWidget *>(child)) {
// 打印子控件的信息,使用缩进表示层级关系
//qDebug() << QString("%1").arg(childWidget->objectName());
2025-10-29 17:23:30 +08:00
QString strObjName = childWidget->objectName();
if(strObjName=="QMyCustomPlot")
{
QMyCustomPlot *form = (QMyCustomPlot*)childWidget;
if(form->m_strLineName == strLineName)
{
childWidget->deleteLater(); // 安排控件的删除,稍后执行
m_listLineName.removeOne(strLineName);
//break;
}
}
}
}
}
void FormDraw::s_delWave(QString strUuid, QString strWellName, QString strTrackName, QString strLineName)
{
//井名&道名不一致
if(strUuid == m_strUuid && m_strWellName == strWellName && m_strTrackName == strTrackName)
{
}
else
{
return;
}
qDebug() << "FormDraw s_delWave";
if(m_listWaveName.contains(strLineName))
{
}
else
{
qDebug() << "FormDraw strLineName not exist! " << strLineName;
return;
}
//
// 获取当前widget的所有子控件
const QObjectList &children = this->children();
// 遍历子控件列表
for (QObject *child : children) {
// 判断子控件是否为QWidget类型
if (QWidget *childWidget = qobject_cast<QWidget *>(child)) {
// 打印子控件的信息,使用缩进表示层级关系
//qDebug() << QString("%1").arg(childWidget->objectName());
QString strObjName = childWidget->objectName();
if(strObjName=="QMyCustomPlot")
{
QMyCustomPlot *form = (QMyCustomPlot*)childWidget;
if(form->m_strLineName == strLineName)
{
childWidget->deleteLater(); // 安排控件的删除,稍后执行
m_listWaveName.removeOne(strLineName);
//break;
}
}
}
}
}
void FormDraw::s_delTableLine(QString strUuid, QString strWellName, QString strTrackName, QString strLineName)
{
//井名&道名不一致
if(strUuid == m_strUuid && m_strWellName == strWellName && m_strTrackName == strTrackName)
{
}
else
{
return;
}
qDebug() << "FormDraw s_delTableLine";
if(m_listTableName.contains(strLineName))
{
}
else
{
qDebug() << "FormDraw strLineName not exist! " << strLineName;
return;
}
//
// 获取当前widget的所有子控件
const QObjectList &children = this->children();
// 遍历子控件列表
for (QObject *child : children) {
// 判断子控件是否为QWidget类型
if (QWidget *childWidget = qobject_cast<QWidget *>(child)) {
// 打印子控件的信息,使用缩进表示层级关系
//qDebug() << QString("%1").arg(childWidget->objectName());
QString strObjName = childWidget->objectName();
if(strObjName=="QMyCustomPlot")
{
QMyCustomPlot *form = (QMyCustomPlot*)childWidget;
if(form->m_strLineName == strLineName)
{
childWidget->deleteLater(); // 安排控件的删除,稍后执行
m_listWaveName.removeOne(strLineName);
//break;
}
}
}
}
}
void FormDraw::s_MouseMove(QString strUuid, QString strWellName, QString strTrackName, float dep)
2025-10-29 17:23:30 +08:00
{
//井名&道名不一致
if(strUuid == m_strUuid && m_strWellName == strWellName && m_strTrackName == strTrackName)
2025-10-29 17:23:30 +08:00
{
}
else
{
return;
}
//qDebug() << "FormDraw s_MouseMove";
2025-10-29 17:23:30 +08:00
//
QString sss=" depth:"+QString::number(dep);
float fValue=-9999;
// 获取当前widget的所有子控件
const QObjectList &children = this->children();
// 遍历子控件列表
for (QObject *child : children) {
// 判断子控件是否为QWidget类型
if (QWidget *childWidget = qobject_cast<QWidget *>(child)) {
// 打印子控件的信息,使用缩进表示层级关系
//qDebug() << QString("%1").arg(childWidget->objectName());
2025-10-29 17:23:30 +08:00
QString strObjName = childWidget->objectName();
if(strObjName=="QMyCustomPlot")
{
QMyCustomPlot *form = (QMyCustomPlot*)childWidget;
//
CLogIO *logio=new CLogIO();
logio->Open(form->m_strSlfName.toStdString().c_str(),CSlfIO::modeRead);
int index=logio->OpenCurve(form->m_strLineName.toStdString().c_str());
if(index<0) {
delete logio;
return;
}
logio->ReadCurve(index, dep, 1, &fValue);
logio->CloseCurve(index);
delete logio;
sss+=" " + form->m_strLineName + ":"+QString::number(fValue);
}
}
}
QStatusBar *pStatusbar = ::GetStatusBar();
if(pStatusbar)
{
pStatusbar->showMessage(sss);
}
}
void FormDraw::s_handleRectRangeChange(QCPRange newRange)
{
}
void FormDraw::setupLineStyleDemo(QMyCustomPlot *customPlot)
{
// customPlot->legend->setVisible(true);
// customPlot->legend->setFont(QFont("Helvetica", 9));
// QPen pen;
// QStringList lineNames;
// lineNames << "lsNone" << "lsLine" << "lsStepLeft" << "lsStepRight" << "lsStepCenter" << "lsImpulse";
// for (int i = QCPGraph::lsNone; i <= QCPGraph::lsImpulse; ++i)
// {
// customPlot->addGraph();
// pen.setColor(QColor(qSin(i*1+1.2)*80+80, qSin(i*0.3+0)*80+80, qSin(i*0.3+1.5)*80+80));
// customPlot->graph()->setPen(pen); // 设置图表的画笔
// customPlot->graph()->setName(lineNames.at(i-QCPGraph::lsNone));
// customPlot->graph()->setLineStyle((QCPGraph::LineStyle)i); // 设置图表线段的风格
// customPlot->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 5)); // 设置图表散点图的样式
// QVector<double> x(15), y(15);
// for (int j=0; j<15; ++j)
// {
// x[j] = j/15.0 * 5*3.14 + 0.01;
// y[j] = 7*qSin(x[j])/x[j] - (i-QCPGraph::lsNone)*5 + (QCPGraph::lsImpulse)*5 + 2;
// }
// customPlot->graph()->setData(x, y);
// customPlot->graph()->rescaleAxes(true);
// }
// // 放大一点
// customPlot->yAxis->scaleRange(1.1, customPlot->yAxis->range().center());
// customPlot->xAxis->scaleRange(1.1, customPlot->xAxis->range().center());
// customPlot->xAxis->setTicks(true);
// customPlot->yAxis->setTicks(true);
// customPlot->xAxis->setTickLabels(true);
// customPlot->yAxis->setTickLabels(true);
// customPlot->axisRect()->setupFullAxesBox();
2025-10-29 17:23:30 +08:00
}
void FormDraw::setupSelectionDemo(QMyCustomPlot *customPlot)
{
//setupLineStyleDemo(customPlot);
customPlot->setInteractions(QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables | QCP::iMultiSelect); // 轴、图例、图表可以被选择,并且是多选的方式
customPlot->setSelectionRectMode(QCP::srmCustom); // 鼠标框选
//customPlot->setSelectionRectMode(QCP::srmSelect); // 鼠标框选
// customPlot->setMultiSelectModifier(Qt::ControlModifier); // 使用ctrl键来多选
// customPlot->xAxis->setSelectableParts(QCPAxis::spAxis | QCPAxis::spAxisLabel | QCPAxis::spTickLabels); // 轴的三个部分都可以被选择
// customPlot->yAxis->setSelectableParts(QCPAxis::spAxis | QCPAxis::spAxisLabel | QCPAxis::spTickLabels);
// customPlot->xAxis->setLabel("xAxis");
// customPlot->yAxis->setLabel("yAxis");
// customPlot->legend->setSelectableParts(QCPLegend::spItems); // 图例本身不能被选择,只有里面的项可以被选择
// customPlot->legend->setSelectedIconBorderPen(Qt::NoPen); // 设置图例里的项被选择时不显示Icon的边框
//选框黑色虚线
//customPlot->selectionRect()->setPen(QPen(Qt::black,1,Qt::DashLine));
//customPlot->selectionRect()->setBrush(QBrush(QColor(0,0,100,50)));
//
// QPen pen(Qt::NoPen); // 使用无画笔,这样就不会有边框了
// QBrush brush(Qt::transparent); // 使用透明刷子,这样就不会有填充颜色了
// customPlot->selectionRect()->setPen(pen); // 设置选择区域的画笔为无画笔
// customPlot->selectionRect()->setBrush(brush); // 设置选择区域的刷子为透明刷子
for (int i=0; i < customPlot->graphCount(); ++i) {
QCPGraph *graph = customPlot->graph(i);
graph->setSelectable(QCP::stDataRange);
}
//connect(customPlot->selectionRect(), SIGNAL(accepted(QRect, QMouseEvent*)), this, SLOT(s_selectionRectAccepted(QRect, QMouseEvent*)));
connect(customPlot->selectionRect(), &QCPSelectionRect::accepted, [customPlot](){
if(customPlot->m_bDrawRect == false)
{
customPlot->m_bDrawRect = true;
return;
}
// 当选择完成时,获取矩形范围并放大
QRectF rect = customPlot->selectionRect()->rect(); // 获取选择的矩形区域(像素坐标)
// 转换为坐标轴范围
double top = rect.top();
double bottom = rect.bottom();
double right_Hight = customPlot->xAxis->pixelToCoord(top);
double left_Low = customPlot->xAxis->pixelToCoord(bottom);
if(right_Hight-left_Low>5)
{
//添加图形
2025-10-30 11:55:37 +08:00
//emit CallManage::getInstance()->sig_addImageToPlot(customPlot, left_Low, right_Hight, ":/image/file.png");
customPlot->addImageToPlot(left_Low, right_Hight, ":/image/file.png");
2025-10-29 17:23:30 +08:00
}
});
// 连接QCustomPlot的信号selectionChangedByUser表明是由鼠标点击进行的选择
// 这里主要就是同步图表和图例的显示
connect(customPlot, &QMyCustomPlot::selectionChangedByUser, [customPlot](){
for (int i=0; i < customPlot->graphCount(); ++i) {
QCPGraph *graph = customPlot->graph(i);
QCPPlottableLegendItem *item = customPlot->legend->itemWithPlottable(graph);
if (item->selected() && !graph->selected())
{
graph->setSelection(QCPDataSelection(graph->data()->dataRange())); // 当图例项被选择时,选择图表全部的数据
}
else if (graph->selected())
{
item->setSelected(true);
QCPDataSelection selection = customPlot->graph(i)->selection();
// 遍历选中的数据范围
for (int j = 0; j < selection.dataRangeCount(); ++j)
{
QCPDataRange dataRange = selection.dataRange(j);
double left_Low = customPlot->graph(i)->data()->at(dataRange.begin())->key;
double right_Hight = customPlot->graph(i)->data()->at(dataRange.end())->key;
if(right_Hight-left_Low>1)
{
//添加图形
2025-10-30 11:55:37 +08:00
//emit CallManage::getInstance()->sig_addImageToPlot(customPlot, left_Low, right_Hight, ":/image/file.png");
customPlot->addImageToPlot(left_Low, right_Hight, ":/image/file.png");
2025-10-29 17:23:30 +08:00
}
}
/*QCPDataSelection selection = customPlot->graph(i)->selection();
// 遍历选中的数据范围
for (int j = 0; j < selection.dataRangeCount(); ++j)
{
QCPDataRange dataRange = selection.dataRange(j);
// 遍历选中范围内的数据点
for (int k = dataRange.begin(); k < dataRange.end(); ++k)
{
double key = customPlot->graph(i)->data()->at(k)->key;
double value = customPlot->graph(i)->data()->at(k)->value;
AppendConsole(PAI_INFO, QString("曲线 %1: (%2, %3)").arg(i).arg(key).arg(value));
}
}*/
}
}
});
}
void FormDraw::s_selectionRectAccepted(const QRect &rect, QMouseEvent *event)
{
// 转换为坐标轴范围
// double x1 = widget->xAxis->pixelToCoord(rect.left());
// double x2 = widget->xAxis->pixelToCoord(rect.right());
// double y1 = widget->yAxis->pixelToCoord(rect.top());
// 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);
}
2025-10-30 11:55:37 +08:00
void FormDraw::initForm(QMyCustomPlot *widget, QString strSlfName, QString strLineName,
double newLeftScale, double newRightScale, QString strScaleType, QColor lineColor, double width, Qt::PenStyle lineStyle)
2025-10-29 17:23:30 +08:00
{
//AppendConsole(PAI_INFO, "FormDraw initForm");
2025-10-29 17:23:30 +08:00
CLogIO *logio=new CLogIO();
logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead);
//
2025-10-29 17:23:30 +08:00
int index=logio->OpenCurve(strLineName.toStdString().c_str());
if(index<0) {
delete logio;
return;
}
Slf_CURVE curveinfo;
float *val;
DWORD count;
float sdep,edep,rlev;
float vmax,vmin;
//
logio->GetCurveInfo(index,&curveinfo);
sdep=curveinfo.StartDepth;
edep=curveinfo.EndDepth;
rlev=curveinfo.DepLevel;
//
count=(curveinfo.EndDepth-curveinfo.StartDepth)/curveinfo.DepLevel+1.5;
val=new float[count];
logio->ReadCurve(index,curveinfo.StartDepth,count,&val[0]);
logio->CloseCurve(index);
delete logio;
QString strAliasName="";
QString strUnit="";
bool bFind = getAliasNameFromIni(strLineName, strAliasName, strUnit);//曲线别名
if(!bFind)
{
strAliasName=strLineName;
}
2025-10-29 17:23:30 +08:00
//最大值,最小值
vmax=vmin=val[0];
2025-11-05 18:15:33 +08:00
2025-10-29 17:23:30 +08:00
//slf文件读取曲线
QVector<double> x, y;
for(int i=0; i<count; i++)
{
2025-10-30 11:55:37 +08:00
if(newLeftScale==-9999)
{
if(vmax<val[i])vmax=val[i];
if(vmin>val[i])vmin=val[i];
}
2025-10-29 17:23:30 +08:00
//
x.append(-(sdep+ rlev*i));
y.append(val[i]);
}
2025-10-30 11:55:37 +08:00
if(newLeftScale!=-9999)
{
vmax = newRightScale;
vmin = newLeftScale;
}
2025-10-29 17:23:30 +08:00
//赋值
m_vmax = vmax;
m_vmin = vmin;
//AppendConsole(PAI_INFO, "FormDraw initForm ReadCurve end");
2025-10-29 17:23:30 +08:00
widget->setInteractions(QCP::iSelectLegend | QCP::iSelectPlottables);
//框选-----
// widget->setInteraction(QCP::iRangeDrag, false); // 关闭拖动
// widget->setSelectionRectMode(QCP::SelectionRectMode::srmSelect); // 启用框选放大
// //
// widget->selectionRect()->setPen(QPen(Qt::black, 1, Qt::DashLine)); // 虚线边框
// widget->selectionRect()->setBrush(QBrush(QColor(0,0,100,50))); // 半透明蓝色填充
// //
// QCPSelectionRect *selectionRect = new QCPSelectionRect(widget);
// connect(selectionRect, &QCPSelectionRect::accepted, [=]() {
// // 当选择完成时,获取矩形范围并放大
// QRectF rect = selectionRect->rect(); // 获取选择的矩形区域(像素坐标)
// // 转换为坐标轴范围
// double x1 = widget->xAxis->pixelToCoord(rect.left());
// double x2 = widget->xAxis->pixelToCoord(rect.right());
// double y1 = widget->yAxis->pixelToCoord(rect.top());
// double y2 = widget->yAxis->pixelToCoord(rect.bottom());
// });
widget->m_iX1 = vmin;
widget->m_iX2 = vmax;
widget->m_iY1 = g_iY1;
widget->m_iY2 = g_iY2;
//
widget->xAxis->setRange(vmin, vmax);
2025-11-10 15:51:41 +08:00
widget->yAxis->setRange(g_iY1, g_iY2);
2025-10-29 17:23:30 +08:00
widget->axisRect()->setupFullAxesBox();
//
widget->xAxis->ticker()->setTickCount(10);//x个主刻度
widget->yAxis->ticker()->setTickCount(60);//y个主刻度
//对调XY轴在最前面设置
QCPAxis *yAxis = widget->yAxis;
QCPAxis *xAxis = widget->xAxis;
widget->xAxis = yAxis;
widget->yAxis = xAxis;
//
if(strScaleType=="对数")
{
widget->yAxis->setScaleType(QCPAxis::stLogarithmic);
}
else //if(m_strScaleType=="线性")
{
widget->yAxis->setScaleType(QCPAxis::stLinear);
}
2025-10-29 17:23:30 +08:00
// //
// widget->yAxis->setRange(vmin, vmax);
// widget->xAxis->setRange(g_iY1, g_iY2);
// widget->axisRect()->setupFullAxesBox();
// //
// widget->yAxis->ticker()->setTickCount(10);//x个主刻度
// widget->xAxis->ticker()->setTickCount(60);//y个主刻度
// //slf文件读取曲线
// QVector<double> x, y;
// for(int i=0; i<count; i++)
// {
// x.append(-(sdep+ rlev*i));
// y.append(val[i]);
// }
2025-10-30 11:55:37 +08:00
if(newLeftScale!=-9999)
{
addRandomGraph(widget, x, y, strSlfName, strLineName, strAliasName, strUnit,
newLeftScale, newRightScale, strScaleType, lineColor, width, lineStyle);
2025-10-30 11:55:37 +08:00
}
else {
addRandomGraph(widget, x, y, strSlfName, strLineName, strAliasName, strUnit);
2025-10-30 11:55:37 +08:00
}
2025-10-29 17:23:30 +08:00
//支持框选
//setupSelectionDemo(widget);
//AppendConsole(PAI_INFO, "FormDraw setupSelectionDemo end");
2025-10-29 17:23:30 +08:00
//widget->rescaleAxes();
//widget->replot();//屏蔽,缩减时间
//AppendConsole(PAI_INFO, "FormDraw initForm end");
2025-10-29 17:23:30 +08:00
}
double GetData(int RepCode,char *buffer)
{
double yy;
if(!buffer) return 0;
switch(RepCode)
{
case REPR_INT: //0
yy=(double)(*((int*)buffer));
break;
case REPR_SHORT: //1
yy=(double)(*((short *)buffer));
break;
case REPR_LONG://2
yy=(double)(*((long *)buffer));
break;
case REPR_FLOAT://3
yy=(double)(*((float *)buffer));
break;
case REPR_DOUBLE://4
yy=(double)(*((double *)buffer));
break;
case REPR_CHAR://5
yy=(double)(*((char *)buffer));
break;
case REPR_UCHAR://6
yy=(double)(*((unsigned char *)buffer));
break;
case REPR_USHORT://7
yy=(double)(*((unsigned short *)buffer));
break;
case REPR_UINT://8
yy=(double)(*((unsigned int *)buffer));
break;
case REPR_ULONG://9
yy=(double)(*((unsigned long *)buffer));
break;
case REPR_STRING://10
yy=-99999;
break;
}
return yy;
}
void FormDraw::initWave(QMyCustomPlot *widget, QString strSlfName, QString strWaveName)
{
CLogIO *logio=new CLogIO();
2025-12-18 17:49:23 +08:00
logio->Open(strSlfName.toStdString().c_str(), CSlfIO::modeRead);
//
int index=logio->OpenWave(strWaveName.toStdString().c_str());
if(index<0) {
delete logio;
return;
}
Slf_WAVE _wave;
logio->GetWaveInfo(index, &_wave);
float _SDep,_EDep,_Rlev;
_SDep = _wave.StartDepth;
_EDep = _wave.EndDepth;
// _SDep = 0.0 - g_iY2;
// _EDep = 0.0 - g_iY1;
_Rlev = _wave.DepLevel;
int m_Record=(float)(fabs((_EDep-_SDep)/_Rlev+0.5));
int _nSamples = _wave.TimeSamples;
char *value=new char[(_nSamples+1)*m_Record*_wave.CodeLen+1];
logio->ReadWave(index,_SDep,m_Record,(void *)value);
logio->CloseWave(index);
delete logio;
bool bFistValue=false;
float vmax = -9999;//(float)_nSamples;
float vmin = -9999;
//
double** wavedata;
wavedata = new double*[_nSamples];
for(int kk = 0;kk<_nSamples;kk++){
wavedata[kk] = new double[m_Record];
}
for (int i=0; i<m_Record; i++)
{
for(int kk = 0;kk<_nSamples;kk++)
{
double val = GetData(_wave.RepCode,(char *)&value[(kk)*_wave.CodeLen+i*_nSamples*_wave.CodeLen]);
wavedata[kk][i] = val;
if(val==-9999)
{
continue;
}
if(bFistValue==false)
{
//最大值,最小值默认采用第一个有效值
bFistValue=true;
vmax = vmin = val;
}
//
2025-11-20 09:42:22 +08:00
if(vmax<val)vmax=val;
if(vmin>val)vmin=val;
}
}
delete[] value;
// g_iY1 = 0.0 -_EDep;
// g_iY2 = 0.0 -_SDep;
//------------------------
widget->m_iX1 = vmin;
widget->m_iX2 = vmax;
widget->m_iY1 = g_iY1;
widget->m_iY2 = g_iY2;
//
widget->xAxis->setRange(vmin, vmax);
widget->yAxis->setRange(g_iY1, g_iY2);
widget->axisRect()->setupFullAxesBox();
//
widget->xAxis->ticker()->setTickCount(10);//x个主刻度
widget->yAxis->ticker()->setTickCount(60);//y个主刻度
//对调XY轴在最前面设置
QCPAxis *yAxis = widget->yAxis;
QCPAxis *xAxis = widget->xAxis;
widget->xAxis = yAxis;
widget->yAxis = xAxis;
//-------------------
// set up the QCPColorMap:
QCPColorMap *colorMap = new QCPColorMap(widget->xAxis, widget->yAxis);
int nx = m_Record;
int ny = _nSamples;
colorMap->data()->setSize(nx, ny); // 我们希望彩色地图有nx*ny的数据点
//colorMap->data()->setRange(QCPRange(g_iY1, g_iY2), QCPRange(vmin, vmax)); // 并在键x和值y维上跨越坐标范围-4..4
colorMap->data()->setRange(QCPRange(0-_EDep, 0-_SDep), QCPRange(vmin, vmax));
// 现在我们通过访问颜色贴图的QCPColorMapData实例来分配一些数据
double x, y, z;
for (int xIndex=0; xIndex<nx; ++xIndex)
{
for (int yIndex=0; yIndex<ny; ++yIndex)
{
2025-11-20 09:42:22 +08:00
if(wavedata[yIndex][xIndex]==-9999)
{
colorMap->data()->setCell(nx-xIndex-1, yIndex, vmin);
2025-11-20 09:42:22 +08:00
continue;
}
//colorMap->data()->setCell(xIndex, yIndex, wavedata[yIndex][xIndex]);
colorMap->data()->setCell(nx-xIndex-1, yIndex, wavedata[yIndex][xIndex]);
}
}
// 添加色标:
QCPColorScale *colorScale = new QCPColorScale(widget);
colorMap->setColorScale(colorScale); // 将颜色图与色标关联
// 将颜色贴图的“颜色渐变”设置为其中一个预设
//colorMap->setGradient(QCPColorGradient::gpPolar);//gpJet);
// 我们还可以创建一个QCPColorGradient实例并向其中添加自己的颜色
// 渐变请参阅QCPColorGradient的文档以获取可能的效果.
int nIndex=11;
QVector<MyColorItem> colorList;
bool inpolation = true;
int iColorNum = getSystemColor(nIndex, colorList, inpolation);
//
QCPColorGradient gradient;
for(int i=0; i<iColorNum; i++)
{
double dbTmpIndex=(double)(i+1)/iColorNum;
gradient.setColorStopAt(dbTmpIndex, colorList[i].color); // x% 位置的颜色
}
colorMap->setGradient(gradient);
// 重新缩放数据维度(颜色),以使所有数据点都位于颜色渐变显示的范围内:
colorMap->rescaleDataRange();
//----调色板--------
// widget->plotLayout()->addElement(0, 1, colorScale); // 将其添加到主轴矩形的右侧
// colorScale->setType(QCPAxis::atRight); // 刻度应为垂直条,刻度线/坐标轴标签右侧(实际上,右侧已经是默认值)
// colorScale->axis()->setLabel("Magnetic Field Strength");
// //确保轴rect和色标同步其底边距和顶边距以便它们对齐:
// QCPMarginGroup *marginGroup = new QCPMarginGroup(widget);
// widget->axisRect()->setMarginGroup(QCP::msBottom|QCP::msTop, marginGroup);
// colorScale->setMarginGroup(QCP::msBottom|QCP::msTop, marginGroup);
// 重新缩放键x和值y以便可以看到整个颜色图
//widget->rescaleAxes();
QString strAliasName = "";
QString strUnit = "";
QColor newlineColor=QColor(0,0,0);
double width=2;
QString strScaleType = "";
//道-对象
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strWaveName, strAliasName, strUnit, newlineColor, width, _nSamples, 0, strScaleType, "waveObject");
2025-12-18 17:49:23 +08:00
}
void FormDraw::initWave_3D(QMyCustomPlot *widget, QString strSlfName, QString strWaveName)
{
CLogIO *logio=new CLogIO();
logio->Open(strSlfName.toStdString().c_str(), CSlfIO::modeRead);
//
int index=logio->OpenWave(strWaveName.toStdString().c_str());
if(index<0) {
delete logio;
return;
}
Slf_WAVE _wave;
logio->GetWaveInfo(index, &_wave);
float _SDep,_EDep,_Rlev;
_SDep = _wave.StartDepth;
_EDep = _wave.EndDepth;
// _SDep = 0.0 - g_iY2;
// _EDep = 0.0 - g_iY1;
_Rlev = _wave.DepLevel;
int m_Record=(float)(fabs((_EDep-_SDep)/_Rlev+0.5));
int _nSamples = _wave.TimeSamples;
char *value=new char[(_nSamples+1)*m_Record*_wave.CodeLen+1];
logio->ReadWave(index,_SDep,m_Record,(void *)value);
logio->CloseWave(index);
delete logio;
bool bFistValue=false;
float vmax = -9999;//(float)_nSamples;
float vmin = -9999;
//
double** wavedata;
wavedata = new double*[_nSamples];
for(int kk = 0;kk<_nSamples;kk++){
wavedata[kk] = new double[m_Record];
}
for (int i=0; i<m_Record; i++)
{
for(int kk = 0;kk<_nSamples;kk++)
{
double val = GetData(_wave.RepCode,(char *)&value[(kk)*_wave.CodeLen+i*_nSamples*_wave.CodeLen]);
wavedata[kk][i] = val;
if(val==-9999)
{
continue;
}
if(bFistValue==false)
{
//最大值,最小值默认采用第一个有效值
bFistValue=true;
vmax = vmin = val;
}
//
if(vmax<val)vmax=val;
if(vmin>val)vmin=val;
}
}
delete[] value;
// vmax = (float)_nSamples;
// vmin = 0;
// g_iY1 = 0.0 -_EDep;
// g_iY2 = 0.0 -_SDep;
//------------------------
widget->m_iX1 = vmin;
widget->m_iX2 = vmax;
widget->m_iY1 = g_iY1;
widget->m_iY2 = g_iY2;
//
widget->xAxis->setRange(vmin, vmax);
widget->yAxis->setRange(g_iY1, g_iY2);
widget->axisRect()->setupFullAxesBox();
//
widget->xAxis->ticker()->setTickCount(10);//x个主刻度
widget->yAxis->ticker()->setTickCount(60);//y个主刻度
2025-12-18 17:49:23 +08:00
//对调XY轴在最前面设置
QCPAxis *yAxis = widget->yAxis;
QCPAxis *xAxis = widget->xAxis;
widget->xAxis = yAxis;
widget->yAxis = xAxis;
//
// 横向点数,全部绘制
int nPoint = _nSamples;
nPoint = nPoint / 2;
// 初始化
float *flSin,*flCos;
QPointF *pt;
flSin = new float[_nSamples+1];
flCos = new float[_nSamples+1];
pt = new QPointF[_nSamples+1];
//
float m_flWjMaxFactor=0.6; //外径最大位置占道的比例
// 最大外径宽度
float r = m_flWjMaxFactor*(_nSamples-0)/2;
//
float centerX = (_nSamples+0)/2.0;
float angle = 3.0*3.1415926/2.0;
float xspeed = (3.1415926/(nPoint-1)); // 半圆
float x=-r;
float m_flVFactor = 0.5;
float centerY = 0;
float y;
for (int j=0;j<nPoint; j++)
{
// 第一种方法:按角度平均分配,图像中间部分有些不真实
//x = sin(angle) * r;
//y = cos(angle) * r*m_flVFactor;
//方法2 :按横向等间距分配,图像边缘部分不太好
// flCos[j] = cos(angle);
// flSin[j] = sin(angle);
y = cos(angle)*r*m_flVFactor;
pt[j].setX(centerX + x);
pt[j].setY(centerY + y);
angle += xspeed;
x += (float)(r*2./(nPoint-1.));
}
//---------------------------------
//转换新值
double** wavedataNew;
wavedataNew = new double*[_nSamples];
for(int kk = 0;kk<_nSamples;kk++){
wavedataNew[kk] = new double[m_Record];
}
//初始化
for (int i=0; i<m_Record; i++)
{
for(int kk = 0;kk<_nSamples;kk++)
{
wavedataNew[kk][i] = vmin;
}
}
for (int i = 0; i < m_Record ; i++)
{
int d=1;
for (int j=0; j<nPoint-d; j+=d)
{
int kkPos = pt[j].x();
int iPos = i+pt[j].y();
if(kkPos>=_nSamples || kkPos<0 || iPos>=m_Record || iPos<0)
{
}
else
{
wavedataNew[kkPos][iPos] = wavedata[j][i];
}
// //----
// kkPos = pt[j].x()+0.5;
// iPos = i+pt[j].y();
// if(kkPos>=_nSamples || kkPos<0 || iPos>=m_Record || iPos<0)
// {
// }
// else
// {
// wavedataNew[kkPos][iPos] = wavedata[j][i];
// }
// //----
// kkPos = pt[j].x()-0.5;
// iPos = i+pt[j].y();
// if(kkPos>=_nSamples || kkPos<0 || iPos>=m_Record || iPos<0)
// {
// }
// else
// {
// wavedataNew[kkPos][iPos] = wavedata[j][i];
// }
// //----
// kkPos = pt[j].x();
// iPos = i+pt[j].y()+0.5;
// if(kkPos>=_nSamples || kkPos<0 || iPos>=m_Record || iPos<0)
// {
// }
// else
// {
// wavedataNew[kkPos][iPos] = wavedata[j][i];
// }
// //----
// kkPos = pt[j].x();
// iPos = i+pt[j].y()-0.5;
// if(kkPos>=_nSamples || kkPos<0 || iPos>=m_Record || iPos<0)
// {
// }
// else
// {
// wavedataNew[kkPos][iPos] = wavedata[j][i];
// }
}
}
//-------------------
// set up the QCPColorMap:
QCPColorMap *colorMap = new QCPColorMap(widget->xAxis, widget->yAxis);
int nx = m_Record;
int ny = _nSamples;
colorMap->data()->setSize(nx, ny); // 我们希望彩色地图有nx*ny的数据点
//colorMap->data()->setRange(QCPRange(g_iY1, g_iY2), QCPRange(vmin, vmax)); // 并在键x和值y维上跨越坐标范围-4..4
colorMap->data()->setRange(QCPRange(0-_EDep, 0-_SDep), QCPRange(vmin, vmax));
// 现在我们通过访问颜色贴图的QCPColorMapData实例来分配一些数据
//double x, y, z;
for (int xIndex=0; xIndex<nx; ++xIndex)
{
for (int yIndex=0; yIndex<ny; ++yIndex)
{
if(wavedataNew[yIndex][xIndex]==-9999)
{
colorMap->data()->setCell(nx-xIndex-1, yIndex, vmin);
continue;
}
//colorMap->data()->setCell(xIndex, yIndex, wavedata[yIndex][xIndex]);
colorMap->data()->setCell(nx-xIndex-1, yIndex, wavedataNew[yIndex][xIndex]);
}
}
// 添加色标:
QCPColorScale *colorScale = new QCPColorScale(widget);
colorMap->setColorScale(colorScale); // 将颜色图与色标关联
// 将颜色贴图的“颜色渐变”设置为其中一个预设
//colorMap->setGradient(QCPColorGradient::gpPolar);//gpJet);
// 我们还可以创建一个QCPColorGradient实例并向其中添加自己的颜色
// 渐变请参阅QCPColorGradient的文档以获取可能的效果.
int nIndex=11;
QVector<MyColorItem> colorList;
bool inpolation = true;
int iColorNum = getSystemColor(nIndex, colorList, inpolation);
//
QCPColorGradient gradient;
for(int i=0; i<iColorNum; i++)
{
double dbTmpIndex=(double)(i+1)/iColorNum;
gradient.setColorStopAt(dbTmpIndex, colorList[i].color); // x% 位置的颜色
}
colorMap->setGradient(gradient);
// 重新缩放数据维度(颜色),以使所有数据点都位于颜色渐变显示的范围内:
colorMap->rescaleDataRange();
//----调色板--------
// widget->plotLayout()->addElement(0, 1, colorScale); // 将其添加到主轴矩形的右侧
// colorScale->setType(QCPAxis::atRight); // 刻度应为垂直条,刻度线/坐标轴标签右侧(实际上,右侧已经是默认值)
// colorScale->axis()->setLabel("Magnetic Field Strength");
// //确保轴rect和色标同步其底边距和顶边距以便它们对齐:
// QCPMarginGroup *marginGroup = new QCPMarginGroup(widget);
// widget->axisRect()->setMarginGroup(QCP::msBottom|QCP::msTop, marginGroup);
// colorScale->setMarginGroup(QCP::msBottom|QCP::msTop, marginGroup);
// 重新缩放键x和值y以便可以看到整个颜色图
//widget->rescaleAxes();
QString strAliasName = "";
QString strUnit = "";
QColor newlineColor=QColor(0,0,0);
double width=2;
QString strScaleType = "";
//道-对象
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strWaveName, strAliasName, strUnit, newlineColor, width, _nSamples, 0, strScaleType, "waveObject");
}
2025-12-18 17:49:23 +08:00
void FormDraw::initWave2(QMyCustomPlot *widget, QString strSlfName, QString strWaveName)
{
CLogIO *logio=new CLogIO();
logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead);
//
int index=logio->OpenWave(strWaveName.toStdString().c_str());
if(index<0) {
delete logio;
return;
}
Slf_WAVE _wave;
logio->GetWaveInfo(index, &_wave);
float _SDep,_EDep,_Rlev;
// _SDep = _wave.StartDepth;
// _EDep = _wave.EndDepth;
g_iY2 = 0 - _wave.StartDepth;
g_iY1 = 0 - _wave.EndDepth;
_SDep = 0.0 - g_iY2;
_EDep = 0.0 - g_iY1;
_Rlev = _wave.DepLevel;
int m_Record=(float)(fabs((_EDep-_SDep)/_Rlev+0.5));
int _nSamples = _wave.TimeSamples;
char *value=new char[(_nSamples+1)*m_Record*_wave.CodeLen+1];
logio->ReadWave(index,_SDep,m_Record,(void *)value);
logio->CloseWave(index);
delete logio;
bool bFistValue=false;
float vmax = (float)_nSamples;
float vmin = 0;
//
double** wavedata;
wavedata = new double*[_nSamples];
for(int kk = 0;kk<_nSamples;kk++){
wavedata[kk] = new double[m_Record];
}
for (int i=0; i<m_Record; i++)
{
for(int kk = 0;kk<_nSamples;kk++)
{
double val = GetData(_wave.RepCode,(char *)&value[(kk)*_wave.CodeLen+i*_nSamples*_wave.CodeLen]);
wavedata[kk][i] = val;
if(val==-9999)
{
continue;
}
//
// if(bFistValue==false)
// {
// //最大值,最小值默认采用第一个有效值
// bFistValue=true;
// vmax = vmin = val;
// }
// if(vmax<val)vmax=val;
// if(vmin>val)vmin=val;
}
}
delete[] value;
// g_iY1 = 0.0 -_EDep;
// g_iY2 = 0.0 -_SDep;
//------------------------
widget->m_iX1 = vmin;
widget->m_iX2 = vmax;
widget->m_iY1 = g_iY1;
widget->m_iY2 = g_iY2;
//
widget->xAxis->setRange(vmin, vmax);
widget->yAxis->setRange(g_iY1, g_iY2);
widget->axisRect()->setupFullAxesBox();
//
widget->xAxis->ticker()->setTickCount(10);//x个主刻度
widget->yAxis->ticker()->setTickCount(60);//y个主刻度
//对调XY轴在最前面设置
// QCPAxis *yAxis = widget->yAxis;
// QCPAxis *xAxis = widget->xAxis;
// widget->xAxis = yAxis;
// widget->yAxis = xAxis;
float nPerHight = 50;//25
float nSpace = 1;
for (int i=0; i<m_Record; i++)
{
//--------------------------------
QVector<double> x;
QVector<double> y;
widget->addGraph();
QString strLineName = "";
if(strLineName=="")
{
strLineName = QString("曲线 %1").arg(widget->graphCount());
}
widget->graph()->setName(strLineName);
for(int kk = 0;kk<_nSamples;kk++)
{
//double val = wavedata[kk][m_Record-i-1];
double val = wavedata[kk][i];
if(val==-9999)
{
continue;
}
//x.append(_nSamples-kk-1);
float tempValue = -(_SDep + nPerHight*_Rlev*i + (val*200*2)/vmax);
x.append(kk);
//float tempValue = -(_SDep + nSpace*i + (val*nPerHight*_Rlev*2)/vmax);
y.append(tempValue);
}
widget->graph()->setData(x, y);
widget->graph()->setLineStyle((QCPGraph::LineStyle)(1));//曲线
widget->graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(1)));
//
QPen graphPen;
QColor newlineColor = QColor(std::rand()%245+10, std::rand()%245+10, std::rand()%245+10);
graphPen.setColor(newlineColor);
double width = 1;
graphPen.setWidthF(width);
graphPen.setStyle(Qt::SolidLine);//实线
widget->graph()->setPen(graphPen);
//widget->replot();
if(i>=20)
break;
}
}
//表格曲线
void FormDraw::initTableLine(QMyCustomPlot *widget, QString strSlfName, QString strLineName)
{
m_Value=NULL;
m_Value2=NULL;
m_Value3=NULL;
//m_csUnit = "(°)";
m_bTableData=0;//表格或曲线
m_LeftVal2=0;
m_RightVal2=360;
//m_csCurveDDIR="DDIR";
//m_csCurveDANG="DANG";
//m_csCurveGrad="GRAD";
m_nTailWidth=2;
m_crTail=qRgb(0,0,0);
m_crPointFill=qRgb(0,0,0);
m_crGridSmall=qRgb(100,100,100);
m_nRadius = 6;
m_nTailLen = 10;
m_nCircleWidth=1;
m_flGrad1 = 10;
m_flGrad2 = 50;
//Table dip
m_qsTable="FRAC_HOLE.TABLE";
m_qsDIR=("DIR"); // 方位 曲线名
m_qsDIP=("DIPorS");//倾角
m_qsDepth="DEP";
m_qsID = "ID";
m_qsProperty=("ID");
m_iPrecision = 3;
//
// ReadFracDef();
// for (int i = 0 ; i < iFracType ; i++)
// {
// m_bTypeDraw[i] = false;
// }
if (m_bTableData)
{
//
m_qsDIR=("DDIR"); // 方位 曲线名
m_qsDIP=("DANG");//倾角
m_qsDepth="DEPT";
m_qsID = "ID";
ReadData(strSlfName, strLineName);
//------------------------
// int nPointNum = m_FracTabList.count();
// if ( nPointNum < 1 )return ;
// FRAC_TABLE frac = m_FracTabList.at(0);
}
else
{
//
m_csCurveDDIR = "DDIR"; // 方位 曲线名
m_csCurveDANG = "DANG";//倾角
m_csCurveGrad = "GRAD";
this->ReadData(strSlfName, m_csCurveDDIR, 0, &m_Curve);
this->ReadData(strSlfName, m_csCurveDANG, 1, &m_Curve2);
this->ReadData(strSlfName, m_csCurveGrad, 2, &m_Curve3);
}
// bool bFistValue=false;
// float vmax = -9999;
// float vmin = -9999;
// //最大值,最小值
// vmax=vmin=frac.DIR;
// //slf文件读取曲线
// for(int i=0; i<nPointNum; i++)
// {
// frac = m_FracTabList.at(i);
// if(frac.DIR==-9999)
// {
// continue;
// }
// if(bFistValue==false)
// {
// //最大值,最小值默认采用第一个有效值
// bFistValue=true;
// vmax = vmin = frac.DIR;
// }
// if(vmax<frac.DIR)vmax=frac.DIR;
// if(vmin>frac.DIR)vmin=frac.DIR;
// }
// widget->m_iX1 = vmin;
// widget->m_iX2 = vmax;
int iMyWidth = widget->axisRect(0)->width();
float vmax = iMyWidth;
float vmin = 0;
widget->m_iX1 = vmin;
widget->m_iX2 = iMyWidth;
widget->m_iY1 = g_iY1;
widget->m_iY2 = g_iY2;
//
widget->xAxis->setRange(vmin, vmax);
widget->yAxis->setRange(g_iY1, g_iY2);
widget->axisRect()->setupFullAxesBox();
//
widget->xAxis->ticker()->setTickCount(10);//x个主刻度
widget->yAxis->ticker()->setTickCount(60);//y个主刻度
//对调XY轴在最前面设置
QCPAxis *yAxis = widget->yAxis;
QCPAxis *xAxis = widget->xAxis;
widget->xAxis = yAxis;
widget->yAxis = xAxis;
m_LeftVal = 0;
m_RightVal = 90;
//隐藏刻度
widget->xAxis->setTicks(false);
widget->yAxis->setTicks(false);
widget->xAxis2->setTicks(false);
widget->yAxis2->setTicks(false);
//
if (m_bTableData)
{
DrawTabDip(widget);
}
else
{
DrawDip(widget);
}
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_RightVal, m_LeftVal, strScaleType, "tableObject");
}
void FormDraw::initWords(QMyCustomPlot *widget, QString strSlfName, QString strLineName)
{
int iMyWidth = widget->axisRect(0)->width();
float vmax = iMyWidth;
float vmin = 0;
widget->m_iX1 = vmin;
widget->m_iX2 = iMyWidth;
widget->m_iY1 = g_iY1;
widget->m_iY2 = g_iY2;
//
widget->xAxis->setRange(vmin, vmax);
widget->yAxis->setRange(g_iY1, g_iY2);
widget->axisRect()->setupFullAxesBox();
//
widget->xAxis->ticker()->setTickCount(10);//x个主刻度
widget->yAxis->ticker()->setTickCount(60);//y个主刻度
//对调XY轴在最前面设置
QCPAxis *yAxis = widget->yAxis;
QCPAxis *xAxis = widget->xAxis;
widget->xAxis = yAxis;
widget->yAxis = xAxis;
m_LeftVal = 0;
m_RightVal = 90;
//隐藏刻度
widget->xAxis->setTicks(false);
widget->yAxis->setTicks(false);
widget->xAxis2->setTicks(false);
widget->yAxis2->setTicks(false);
//
LoadFromSLF(widget, strSlfName, strLineName);
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_RightVal, m_LeftVal, strScaleType, "tableObject");
}
bool FormDraw::LoadFromSLF(QMyCustomPlot *widget, QString strSlfName, QString strLineName)
{
QString FieldName="RESULT";
{
QString ss=strSlfName;
CMemRdWt *logio=new CMemRdWt();
if(ss==""||!logio->Open(ss.toStdString().c_str(),CSlfIO::modeRead))
{
delete logio;
// QMessageBox::information(NULL,"提示","SLF文件打开失败请检查",QMessageBox::Yes);
return false;
}
int iIndex=logio->OpenTable(strLineName.toStdString().c_str());
if(iIndex>-1) {
int len=logio->GetTableRecordLength(iIndex);
if(len<sizeof(WORDS_DATA)) len=sizeof(WORDS_DATA);
char*buf=new char[len+1];
WORDS_DATA *m_Result=(WORDS_DATA *)buf;
int count=logio->GetTableRecordCount(iIndex);
for(int i=0;i<count;i++) {
memset(m_Result,0,sizeof(WORDS_DATA));
logio->ReadTable(iIndex,i+1,m_Result);
// WelllogItem* item=AddItem(m_Result->StartDepth,m_Result->EndDepth);
// if(!item) continue;
// OGWordsResultItem* pResult = dynamic_cast<OGWordsResultItem*>(item);
logio->GetTableFieldData(iIndex,(char*)FieldName.toStdString().c_str(),m_Result->Words,i+1);
if(strstr(m_Result->Words,"$L")) {
char *s=strstr(m_Result->Words,"$L");
if(strstr(s+2,"$U")) {
char *p=strstr(s+1,"$U");
int len=p-s-2;
char buf1[100];
strncpy(buf1,s+2,len);
buf1[len]=0;
// SetLeftAndRightAlign(atoi(buf1));
// SetUpAndDownAlign(atoi(p+2));
}
else {
// SetLeftAndRightAlign(atoi(s+2));
}
*s=0;
}
else if(strstr(m_Result->Words,"$U")){
char *p=strstr(m_Result->Words,"$U");
// SetUpAndDownAlign(atoi(p+2));
*p=0;
}
// SetCharacters(m_Result->Words);
// fontColor=QColor(0,0,0,255);
// backgroundColor=QColor(255,255,255,255);
// wordfont.setFamily("黑体");
// wordfont.setPointSize(10);
//显示文本
widget->addTextToPlot(-m_Result->EndDepth, -m_Result->StartDepth, QString::fromLocal8Bit(m_Result->Words));
//widget->addTextToPlot(-2910, -2900, "你好");//QString(m_Result->Words)
}
logio->CloseTable(iIndex);
delete buf;
}
delete logio;
}
return true;
}
//解释结论
void FormDraw::initResult(QMyCustomPlot *widget, QString strSlfName, QString strLineName)
{
int iMyWidth = widget->axisRect(0)->width();
float vmax = iMyWidth;
float vmin = 0;
widget->m_iX1 = vmin;
widget->m_iX2 = iMyWidth;
widget->m_iY1 = g_iY1;
widget->m_iY2 = g_iY2;
//
widget->xAxis->setRange(vmin, vmax);
widget->yAxis->setRange(g_iY1, g_iY2);
widget->axisRect()->setupFullAxesBox();
//
widget->xAxis->ticker()->setTickCount(10);//x个主刻度
widget->yAxis->ticker()->setTickCount(60);//y个主刻度
//对调XY轴在最前面设置
QCPAxis *yAxis = widget->yAxis;
QCPAxis *xAxis = widget->xAxis;
widget->xAxis = yAxis;
widget->yAxis = xAxis;
m_LeftVal = 0;
m_RightVal = 90;
//隐藏刻度
widget->xAxis->setTicks(false);
widget->yAxis->setTicks(false);
widget->xAxis2->setTicks(false);
widget->yAxis2->setTicks(false);
//
LoadFromSLF_Result(widget, strSlfName, strLineName);
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_RightVal, m_LeftVal, strScaleType, "tableObject");
}
//录井剖面
void FormDraw::initGeoLith(QMyCustomPlot *widget, QString strSlfName, QString strLineName)
{
int iMyWidth = widget->axisRect(0)->width();
float vmax = iMyWidth;
float vmin = 0;
widget->m_iX1 = vmin;
widget->m_iX2 = iMyWidth;
widget->m_iY1 = g_iY1;
widget->m_iY2 = g_iY2;
//
widget->xAxis->setRange(vmin, vmax);
widget->yAxis->setRange(g_iY1, g_iY2);
widget->axisRect()->setupFullAxesBox();
//
widget->xAxis->ticker()->setTickCount(10);//x个主刻度
widget->yAxis->ticker()->setTickCount(60);//y个主刻度
//对调XY轴在最前面设置
QCPAxis *yAxis = widget->yAxis;
QCPAxis *xAxis = widget->xAxis;
widget->xAxis = yAxis;
widget->yAxis = xAxis;
m_LeftVal = 0;
m_RightVal = 90;
//隐藏刻度
widget->xAxis->setTicks(false);
widget->yAxis->setTicks(false);
widget->xAxis2->setTicks(false);
widget->yAxis2->setTicks(false);
//
LoadFromSLF_GeoLith(widget, strSlfName, strLineName);
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_RightVal, m_LeftVal, strScaleType, "tableObject");
}
bool FormDraw::LoadFromSLF_GeoLith(QMyCustomPlot *widget, QString strSlfName, QString strLineName)
{
CMemRdWt *logio=new CMemRdWt();
if(!logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead))
{
delete logio;
return false;
}
int iIndex=logio->OpenTable(strLineName.toStdString().c_str());
if(iIndex>-1) {
int len=logio->GetTableRecordLength(iIndex);
int sl=sizeof(GeoLith_DATA);
if(sl>len) len=sl;
GeoLith_DATA *m_Result;
m_Result=(GeoLith_DATA *)new char[len+1];
int count=logio->GetTableRecordCount(iIndex);
for(int i=0;i<count;i++) {
memset(m_Result,0,len);
logio->ReadTable(iIndex,i+1,m_Result);
//
QMap<QString,QString> OilOrder;
QMap<QString,QString> LithOrder;
QMap<QString,QString> ColorOrder;
QMap<QString,QString> ColorInds;
//
LithOrder=GetZoneOrder(QString("GeoLith"));
OilOrder=GetZoneOrder(QString("CoreOil"));
ColorOrder=GetZoneOrder(QString("CoreColor"));
ColorInds=GetZoneOrder(QString("ColorInd"));
QString iconshotname="";
QString IntLith = QString::number(m_Result->Lith);
if(IntLith=="0") {
iconshotname="";
}
else
{
iconshotname=LithOrder.key(IntLith);
}
//
QString Lith = "";
if(iconshotname!="")
Lith=::GetMudSymbolDir()+""+iconshotname+".svg";
int len=2;
int pos=Lith.indexOf(".//");
if(pos<0) pos=Lith.indexOf("./");
else len=3;
QString svg;
if(pos==0)
{
svg=QCoreApplication::applicationDirPath()+ QDir::separator();
svg+=Lith.mid(len-1);
}
else svg=Lith;
QDir ss;
if(!ss.exists(svg))
{
QString path=svg.left(svg.lastIndexOf('.')+1);
svg=path+"png";
}
Lith=svg;
//
QString Oil = "";
iconshotname=OilOrder.key(QString::number(m_Result->Oil));
if(iconshotname!="")
Oil=::GetGasSymbolDir()+""+iconshotname+".svg";
len=2;
pos=Oil.indexOf(".//");
if(pos<0) pos=Oil.indexOf("./");
else len=3;
if(pos==0)
{
svg=QCoreApplication::applicationDirPath()+ QDir::separator();
svg+=Oil.mid(len-1);
}
else svg=Oil;
if(!ss.exists(svg))
{
QString path=svg.left(svg.lastIndexOf('.')+1);
svg=path+"png";
}
Oil=svg;
//
QString Color = "";
int ind=ColorInds.value(QString::number(m_Result->Color)).toInt();
if (ind>-1&&ind<ColorOrder.size())
{
Color=::GetColorSymbolDir()+""+ColorOrder.key(QString::number(ind))+".svg";
}
else {
Color=::GetColorSymbolDir()+"空白.svg";
}
//
widget->addGeoLithToPlot(-m_Result->EDEP, -m_Result->SDEP, Lith, Oil, Color);
}
logio->CloseTable(iIndex);
delete m_Result;
}
delete logio;
return true;
}
bool FormDraw::LoadFromSLF_Result(QMyCustomPlot *widget, QString strSlfName, QString strLineName)
{
static bool isrun=false;
CMemRdWt *logio=new CMemRdWt();
if(!logio->Open(strSlfName.toStdString().c_str(), CSlfIO::modeRead))
{
delete logio;
isrun=false;
return false;
}
int iIndex=logio->OpenTable(strLineName.toStdString().c_str());
if(iIndex>-1) {
int len = logio->GetTableRecordLength(iIndex);
int sl = sizeof(LAYER_DATA);
if(sl>len) len=sl;
LAYER_DATA *m_Result,*m_Result1;
int count=logio->GetTableRecordCount(iIndex);
char *pstr=new char[len*count+1];
memset(pstr,0,len*count);
int zone=1;
for(int i=0;i<count;i++) {
m_Result=(LAYER_DATA *)(pstr+i*len);
logio->ReadTable(iIndex,i+1,m_Result);
if(!i) zone=atoi(m_Result->Zone);
}
for(int i=0;i<count;i++)
{
m_Result=(LAYER_DATA *)(pstr+i*len);
if(m_Result->StartDepth==m_Result->EndDepth) continue;
//以下字段为临时添加后面需要和pai数据组集成
//tmp code
QString resultNo;//解释层号
QString result;//油气结论
double thick;//有效厚度
double tt;//累计厚度
QString result1;//油气结论2
QString result2;//油气结论3
QString result3;//油气结论3
QString result4;//油气结论3
QString result5;//油气结论3
QString result6;//油气结论2
QString result7;//油气结论3
QString result8;//油气结论3
QString result9;//油气结论3
QString result10;//油气结论3
float m_MDepth1;
float m_MDepth2;
float m_MDepth3;
float m_MDepth4;
float m_MDepth5;
float m_MDepth6;
float m_MDepth7;
float m_MDepth8;
float m_MDepth9;
float m_MDepth10;
2025-12-11 15:11:20 +08:00
QString strZone = QString::number(atoi(m_Result->Zone));
QString Description1;
QString Description2;
QString Description3;
QString Description4;
QString Description5;
QString Description6;
QString Description7;
QString Description8;
QString Description9;
QString Description10;
int m_GEOName;
QString m_DEST;
float m_SDEP,m_EDEP;
float m_SDEP1,m_EDEP1;
float m_SDEP2,m_EDEP2;
float m_SDEP3,m_EDEP3;
float m_SDEP4,m_EDEP4;
float m_SDEP5,m_EDEP5;
float m_SDEP6,m_EDEP6;
float m_SDEP7,m_EDEP7;
float m_SDEP8,m_EDEP8;
float m_SDEP9,m_EDEP9;
float m_SDEP10,m_EDEP10;
//0代表直接绘制 1代表平铺 2代表拉伸 默认值是2
QMap<QString,QString> zoneOrder = GetZoneOrder();//初始化ZoneOrder 层序号根据层位名来配置文件在conf\\RESULT.txt
//
QDir fexit;
QString result_str=QString::number(m_Result->Result);
QString iconshotname;
if(result_str.length()>0&&m_Result->MDepth1)
iconshotname=zoneOrder.key(result_str.at(0));
else
iconshotname=zoneOrder.key(result_str);
if(iconshotname!=""){
result=::GetOilSymbolDir()+iconshotname+".svg";
if(!fexit.exists(result))
{
result=::GetOilSymbolDir()+iconshotname+".png";
}
}
if(m_Result->MDepth1!=0) {
if(result_str.length()>1) iconshotname=zoneOrder.key(QString::number(m_Result->Result).at(1));
if(iconshotname!=""){
result1=::GetOilSymbolDir()+iconshotname+".svg";
if(!fexit.exists(result1))
result1=::GetOilSymbolDir()+iconshotname+".png";
}
}
if(m_Result->MDepth2!=0) {
if(result_str.length()>2) iconshotname=zoneOrder.key(result_str.at(2));
if(iconshotname!=""){
result2=::GetOilSymbolDir()+iconshotname+".svg";
if(!fexit.exists(result2))
result2=::GetOilSymbolDir()+iconshotname+".png";
}
}
if(m_Result->MDepth3!=0) {
if(result_str.length()>3) iconshotname=zoneOrder.key(result_str.at(3));
if(iconshotname!=""){
result3=::GetOilSymbolDir()+iconshotname+".svg";
if(!fexit.exists(result3))
result3=::GetOilSymbolDir()+iconshotname+".png";
}
}
if(m_Result->MDepth4!=0) {
if(result_str.length()>4) iconshotname=zoneOrder.key(result_str.at(4));
if(iconshotname!=""){
result4=::GetOilSymbolDir()+iconshotname+".svg";
if(!fexit.exists(result4))
result4=::GetOilSymbolDir()+iconshotname+".png";
}
}
if(m_Result->MDepth5!=0) {
if(result_str.length()>5) iconshotname=zoneOrder.key(result_str.at(5));
if(iconshotname!=""){
result5=::GetOilSymbolDir()+iconshotname+".svg";
if(!fexit.exists(result5))
result5=::GetOilSymbolDir()+iconshotname+".png";
}
}
if(m_Result->MDepth6!=0) {
if(result_str.length()>6) iconshotname=zoneOrder.key(result_str.at(6));
if(iconshotname!=""){
result6=::GetOilSymbolDir()+iconshotname+".svg";
if(!fexit.exists(result6))
result6=::GetOilSymbolDir()+iconshotname+".png";
}
}
if(m_Result->MDepth7!=0) {
if(result_str.length()>7) iconshotname=zoneOrder.key(result_str.at(7));
if(iconshotname!=""){
result7=::GetOilSymbolDir()+iconshotname+".svg";
if(!fexit.exists(result7))
result7=::GetOilSymbolDir()+iconshotname+".png";
}
}
if(m_Result->MDepth8!=0) {
if(result_str.length()>8) iconshotname=zoneOrder.key(result_str.at(8));
if(iconshotname!=""){
result8=::GetOilSymbolDir()+iconshotname+".svg";
if(!fexit.exists(result8))
result8=::GetOilSymbolDir()+iconshotname+".png";
}
}
if(m_Result->MDepth9!=0) {
if(result_str.length()>9) iconshotname=zoneOrder.key(result_str.at(9));
if(iconshotname!=""){
result9=::GetOilSymbolDir()+iconshotname+".svg";
if(!fexit.exists(result9))
result9=::GetOilSymbolDir()+iconshotname+".png";
}
}
if(m_Result->MDepth10!=0) {
if(result_str.length()>10) iconshotname=zoneOrder.key(result_str.at(10));
if(iconshotname!=""){
result10=::GetOilSymbolDir()+iconshotname+".svg";
if(!fexit.exists(result10))
result10=::GetOilSymbolDir()+iconshotname+".png";
}
}
//
QString strUuid = "";
if(result != "")
{
if(m_Result->MDepth1!=0)
{
2025-12-11 15:11:20 +08:00
//第一个加Zone解释层号
widget->addResultToPlot(-m_Result->MDepth1, -m_Result->StartDepth, result, strUuid, strZone);
}
else {
2025-12-11 15:11:20 +08:00
widget->addResultToPlot(-m_Result->EndDepth, -m_Result->StartDepth, result, strUuid, strZone);
}
}
if(result1 != "")
{
if(m_Result->MDepth2!=0)
{
widget->addResultToPlot(-m_Result->MDepth2, -m_Result->MDepth1, result1, strUuid);
}
else {
widget->addResultToPlot(-m_Result->EndDepth, -m_Result->MDepth1, result1, strUuid);
}
}
if(result2 != "")
{
if(m_Result->MDepth3!=0)
{
widget->addResultToPlot(-m_Result->MDepth3, -m_Result->MDepth2, result2, strUuid);
}
else {
widget->addResultToPlot(-m_Result->EndDepth, -m_Result->MDepth2, result2, strUuid);
}
}
if(result3 != "")
{
if(m_Result->MDepth4!=0)
{
widget->addResultToPlot(-m_Result->MDepth4, -m_Result->MDepth3, result3, strUuid);
}
else {
widget->addResultToPlot(-m_Result->EndDepth, -m_Result->MDepth3, result3, strUuid);
}
}
if(result4 != "")
{
if(m_Result->MDepth5!=0)
{
widget->addResultToPlot(-m_Result->MDepth5, -m_Result->MDepth4, result4, strUuid);
}
else {
widget->addResultToPlot(-m_Result->EndDepth, -m_Result->MDepth4, result4, strUuid);
}
}
if(result5 != "")
{
if(m_Result->MDepth6!=0)
{
widget->addResultToPlot(-m_Result->MDepth6, -m_Result->MDepth5, result5, strUuid);
}
else{
widget->addResultToPlot(-m_Result->EndDepth, -m_Result->MDepth5, result5, strUuid);
}
}
if(result6 != "")
{
if(m_Result->MDepth6!=0)
{
widget->addResultToPlot(-m_Result->MDepth7, -m_Result->MDepth6, result6, strUuid);
}
else {
widget->addResultToPlot(-m_Result->EndDepth, -m_Result->MDepth6, result6, strUuid);
}
}
if(result7 != "")
{
if(m_Result->MDepth8!=0)
{
widget->addResultToPlot(-m_Result->MDepth8, -m_Result->MDepth7, result7, strUuid);
}
else {
widget->addResultToPlot(-m_Result->EndDepth, -m_Result->MDepth7, result7, strUuid);
}
}
if(result8 != "")
{
if(m_Result->MDepth9!=0)
{
widget->addResultToPlot(-m_Result->MDepth9, -m_Result->MDepth8, result8, strUuid);
}
else {
widget->addResultToPlot(-m_Result->EndDepth, -m_Result->MDepth8, result8, strUuid);
}
}
if(result9 != "")
{
if(m_Result->MDepth10!=0)
{
widget->addResultToPlot(-m_Result->MDepth10, -m_Result->MDepth9, result9, strUuid);
}
else{
widget->addResultToPlot(-m_Result->EndDepth, -m_Result->MDepth9, result9, strUuid);
}
}
if(result10 != "")
{
if(m_Result->MDepth10!=0)
{
widget->addResultToPlot(-m_Result->EndDepth, -m_Result->MDepth10, result10, strUuid);
}
}
}
logio->CloseTable(iIndex);
delete pstr;
}
delete logio;
isrun=false;
return true;
}
2025-11-26 11:24:46 +08:00
void FormDraw::CalcDipWidth(int nColumn,float *flWidth,float factor,int x1,int x2,float flHoriRatio)
{
float scale ;
int k;
scale = flWidth[0]=1.;
for(k=1;k<nColumn;k++)
{
flWidth[k] = flWidth[k-1] / factor;
scale += flWidth[k];
}
scale = /*100. **/flHoriRatio*(x2 - x1) / scale;
for(k=0;k<nColumn;k++)
{
flWidth[k] = flWidth[k] * scale;
}
}
void FormDraw::DrawDip(QMyCustomPlot *widget)
{
float flWidth[50];
int l;
float dep;
int m_nScaleThinGrid=10;
// 计算位置
int iMyWidth = widget->axisRect(0)->width();
float x1 = 0;
float x2 = iMyWidth;
float x=0,y=0;
int j=0,i=0,k=0;
float flTemp=0;
for(int i=0;i<50;i++) flWidth[i]=0;
CalcDipWidth(m_nScaleThinGrid, flWidth, 1.2, x1, x2, 1.);
//绘制网格线,注意颜色、宽度属性
QPen pPenStraightLine(m_crTail, m_nTailWidth);
QPen pPenStraightLineSmall(m_crGridSmall, m_nTailWidth/2);
for(i=0;i<m_nScaleThinGrid;i++)
{
if ( i == 0 ) x =1;
else x = x1;
x1 = x + flWidth[i];
if ( (x1-x) <= 7) {
l = 2; // 小于1厘米
}
else l = 5;
for ( j=0; j<l; j++)
{
flTemp = (x + j*(x1 - x)/l);
double dtick=flTemp;
if(i==0&&j==0) continue;
{
QCPItemStraightLine *qcpItemLine = new QCPItemStraightLine(widget);
qcpItemLine->point1->setCoords(-m_SDep, dtick);//位置
qcpItemLine->point2->setCoords(-m_EDep, dtick);//位置
if(j==0)
{
qcpItemLine->setPen(pPenStraightLine);
}
else
{
qcpItemLine->setPen(pPenStraightLineSmall);
}
}
}
}
QPen pPen(m_crTail,m_nTailWidth);
QBrush cBrushFill(m_crPointFill);
float flDepthScale,tempf,flVal;
int nPointNum=0,tempi;
QRectF rt,rtRect;
float dgtord,dr;
for(int i=0;i<50;i++) flWidth[i]=0;
if(m_Value==0 || m_Value2==0)
{
Refurbish();
}
if ( m_Value==0 || m_Value2==0 )
return ;
dgtord=3.14159265/180.;
CalcDipWidth(9, flWidth, 1.2, 0, iMyWidth, 1);
while ( 1)
{
dep = m_SDep + k * m_Rlev;
if ( dep >m_EDep )
break;
if(dep<m_SDep)
{
k++;
continue;
}
i=(dep-m_Curve2.StartDepth)/m_Curve2.DepLevel+0.5;
if(i<0)
{
k++;
continue;
}
flVal = GetData(m_Curve2.RepCode,(char *)&m_Value2[i*m_Curve2.CodeLen]);//DANG
if ( flVal > m_RightVal || flVal < m_LeftVal )
{
k++;
continue;
}
tempi = (int)( flVal /10.);
tempf = 0.;
for (j=0; j<tempi; j++)
{
tempf += flWidth[j];
}
x = tempf + (flVal-tempi*10.)*(flWidth[j+1]/10.);
y = -dep;//起始深度
// pDC->setPen(pPen);// [5/22/2019 9:43 hxb]
// rtRect.setLeft(x - GetLineWidth(pDC,m_nRadius));
// rtRect.setRight(x + GetLineWidth(pDC,m_nRadius));
// rtRect.setBottom(y +GetLineWidth(pDC,m_nRadius));
// rtRect.setTop(y -GetLineWidth(pDC,m_nRadius));
// pDC->setPen(PenCircle);
// pDC->drawEllipse(rtRect.center(),m_nRadius,m_nRadius);
QCPItemEllipse *qcpItemEllipse = new QCPItemEllipse(widget);
qcpItemEllipse->setPen(pPen);
qcpItemEllipse->m_bCustom = true;
qcpItemEllipse->m_nRadius = m_nRadius;
qcpItemEllipse->topLeft->setCoords(y, x);//圆心位置
qcpItemEllipse->bottomRight->setCoords(y, x);//圆心位置
qcpItemEllipse->setBrush(cBrushFill);//填充圆的颜色
//方位
flVal = GetData(m_Curve.RepCode,(char *)&m_Value[i*m_Curve.CodeLen]);//DDIR
dr=flVal*dgtord;
// // 注意映射方式
// x +=GetLineWidth(pDC,m_nRadius)*sin(dr);
// y -=GetLineWidth(pDC,m_nRadius)*cos(dr);
// float x1=x +GetLineWidth(pDC,m_nTailLen)*sin(dr);
// float y1=y -GetLineWidth(pDC,m_nTailLen)*cos(dr);
// pDC->setPen(pPen);
// pDC->drawLine(QPointF(x,y),QPointF(x1,y1));
QCPItemLine *qcpItemLine = new QCPItemLine(widget);
qcpItemLine->start->setCoords(y, x);//圆心位置
qcpItemLine->end->setCoords(y, x);//圆心位置
qcpItemLine->setPen(pPen);
qcpItemLine->m_bCustom = true;
qcpItemLine->m_nTailLen = m_nTailLen; //尾长
qcpItemLine->m_nRadius = m_nRadius; //半径
qcpItemLine->m_dr = dr;
//移动对象
// widget->mSizeHandleManager->addItem(qcpItemEllipse, true);
// widget->mSizeHandleManager->addItem(qcpItemLine, true);
k++;
}
}
void FormDraw::DrawTabDip(QMyCustomPlot *widget)
{
float flDepthScale,tempf,flVal;
int i,j,n,nPointNum=0,tempi;
QRectF rt,rtRect;
float x,y;
float dgtord,dr;
float flWidth[50];
FRAC_TABLE frac;
bool bDraw;
FRAC_DEF fd;
//CString cs;
if(m_iPrecision<0) m_iPrecision=0;
nPointNum = m_FracTabList.count();
if ( nPointNum < 1 )return ;
dgtord=3.14159265/180.;
//
m_nCircleWidth = 1;
m_nRadius = 6;
m_crCircle = QColor(0,0,0);
//
m_nTailWidth = 2;
m_nTailLen = 10;
m_crTail = QColor(0,0,0);
int iMyWidth = widget->axisRect(0)->width(); //setSizeConstraintRect()
int iMyHeight = widget->axisRect(0)->height(); //setSizeConstraintRect()
qDebug() << "iMyWidth=" << QString::number(iMyWidth) << ", iMyHeight=" << QString::number(iMyHeight);
//-----------
int l;
float x1 = 0;
float x2 = iMyWidth;
float flTemp=0;
for(int i=0;i<50;i++) flWidth[i]=0;
int m_nScaleThinGrid=10;
CalcDipWidth(m_nScaleThinGrid, flWidth, 1.2, x1, x2, 1.);
//绘制网格线,注意颜色、宽度属性
QPen pPenStraightLine(m_crTail, m_nTailWidth);
QPen pPenStraightLineSmall(m_crGridSmall, m_nTailWidth/2);
for(i=0;i<m_nScaleThinGrid;i++)
{
if ( i == 0 ) x =1;
else x = x1;
x1 = x + flWidth[i];
if ( (x1-x) <= 7) {
l = 2; // 小于1厘米
}
else l = 5;
for ( j=0; j<l; j++)
{
flTemp = (x + j*(x1 - x)/l);
double dtick=flTemp;
if(i==0&&j==0) continue;
{
QCPItemStraightLine *qcpItemLine = new QCPItemStraightLine(widget);
qcpItemLine->point1->setCoords(-g_iY2, dtick);//位置
qcpItemLine->point2->setCoords(-g_iY1, dtick);//位置
if(j==0)
{
qcpItemLine->setPen(pPenStraightLine);
}
else
{
qcpItemLine->setPen(pPenStraightLineSmall);
}
}
}
}
CalcDipWidth(9,flWidth, 1.2, 0, iMyWidth, 1.);
2025-11-26 11:24:46 +08:00
n = m_FracDefList.count();
for (i=0; i<nPointNum; i++)
{
frac = m_FracTabList.at(i);
// if ( frac.DEP < -g_iY2 || frac.DEP > -g_iY1)
// {
// continue;
// }
// bDraw = false;
// for (j=0; j<n; j++)
// {
// fd = m_FracDefList.at(j);
// // 裂缝描述表中未保存裂缝名称:
// //比较裂缝名称比较准确,代码更改,如果比较代码会引起不一致性
// if ( (int)(frac.ID) == fd.iCode )
// {
// bDraw = m_bTypeDraw[j];//fd.bDraw;
// break;
// }
// }
//if ( bDraw )
{
QBrush cBrush(fd.crColor);
//圆圈
QPen pPen(m_crCircle);
pPen.setWidth(m_nCircleWidth);
//尾巴
QPen pPenTail(m_crTail);
pPenTail.setWidth(m_nTailWidth);
// 角度
2025-11-26 11:24:46 +08:00
flVal = frac.DIPorS;
tempf = flVal /10.;
tempi = tempf;
x = fmod(flVal,(float)(10.));
if ( x == 0 )
{
tempi=0;//tempi --;
}
tempf = 0.;
for (j=0; j<tempi; j++)
tempf += flWidth[j];
x = tempf+(flVal-tempi*10.)*(flWidth[tempi]/10.);
//x = frac.DIPorS;
y = -frac.DEP;
// int LineWidth = m_nRadius;
// rtRect.setLeft(x - LineWidth);
// rtRect.setRight( x + LineWidth);
// rtRect.setBottom( y + LineWidth);
// rtRect.setTop(y - LineWidth);
// pDC->setPen(pPen);
// pDC->drawEllipse(rtRect.left(),rtRect.top(),rtRect.width(),rtRect.height());
// QPainterPath myPath;
// myPath.addEllipse(rtRect);
// pDC->fillPath(myPath,cBrush);
//CustomEllipse *qcpitemellipse = new CustomEllipse(widget);
QCPItemEllipse *qcpItemEllipse = new QCPItemEllipse(widget);
qcpItemEllipse->setPen(pPen);
qcpItemEllipse->m_bCustom = true;
qcpItemEllipse->m_nRadius = m_nRadius;
qcpItemEllipse->topLeft->setCoords(y, x);//圆心位置
qcpItemEllipse->bottomRight->setCoords(y, x);//圆心位置
qcpItemEllipse->setBrush(cBrush);//填充圆的颜色
//方位
dr=frac.DIR *dgtord;
// QCPItemStraightLine *qcpItemLine = new QCPItemStraightLine(widget);
// qcpItemLine->point1->setCoords(y, x);//圆心位置
// qcpItemLine->point2->setCoords(y, x);//圆心位置
QCPItemLine *qcpItemLine = new QCPItemLine(widget);
qcpItemLine->start->setCoords(y, x);//圆心位置
qcpItemLine->end->setCoords(y, x);//圆心位置
qcpItemLine->setPen(pPenTail);
qcpItemLine->m_bCustom = true;
qcpItemLine->m_nTailLen = m_nTailLen; //尾长
qcpItemLine->m_nRadius = m_nRadius; //半径
qcpItemLine->m_dr = dr;
//break;
// x += m_nRadius*sin(dr);
// // 注意映射方式
// y -=m_nRadius*cos(dr);
// //pDC->moveto(x,y);
// float x1=x +m_nTailLen*sin(dr);
// // 注意映射方式
// float y1= y-m_nTailLen*cos(dr);
// pDC->setPen(pPenTail);
// pDC->drawLine(x,y,x1,y1);
// if ( m_bDrawValue ) //显示倾角、方位
// {
// rtRect.setTop(rtRect.top()-GetLineWidth(pDC,objViewInfo->GetLogUnitFont().pointSize()));
// rtRect.setBottom(rtRect.bottom()+GetLineWidth(pDC,objViewInfo->GetLogUnitFont().pointSize()));
// QString cs1 = QString::number(frac.DIPorS,'f',m_iPrecision);
// QString cs2 = QString::number(frac.DIR,'f',m_iPrecision);
// cs=cs1+"//"+cs2;
// cs.Replace((" "),"");
// if ( frac.DIPorS >= 30 )
// {
// x = 2.*(float)(GetLineWidth(pDC,m_nRadius));
// rtRect.setRight(rtRect.center().x() - x);
// rtRect.setLeft(mrt.left());
// pDC->drawText(rtRect,Qt::AlignVCenter|Qt::AlignHCenter,cs.GetString());
// }
// else
// {
// x = 2.*(float)(GetLineWidth(pDC,m_nRadius));
// rtRect.setLeft(rtRect.center().x() + x);
// rtRect.setRight(mrt.right());
// pDC->drawText(rtRect,Qt::AlignVCenter,cs.GetString());
// }
// }
}
}
}
//read config file: FRAC.CFG,save info into m_FracDef
void FormDraw::ReadFracDef()
{
m_FracDefList.clear();
FRAC_DEF fd;
//char path[MAX_PATH+1];
char str[512],name[512];
int r,g,b,id;
FILE *fp;
QString qs;
//sprintf(str,"%sconf\\FRAC.CFG",path);
QString fracFilePath = GetConfPath() + "FRAC_New.CFG";
fp = fopen(fracFilePath.toStdString().c_str(),"r");
if ( fp !=NULL )
{
fgets(str,256,fp); // 跳过第一行
while (!feof(fp))
{
fgets(str,256,fp);
qs = str; qs.trimmed();
if (qs.length() < 8) break ;
//代码 名称 形状代码(1:正弦曲线 2:连线 3:封闭区域) 颜色(红 绿 蓝) 线宽度
sscanf(str,"%d %s %d %d %d %d %d",&fd.iCode, name, &fd.iType, &r, &g, &b, &fd.nLineWidth);
fd.crColor = QColor(r,g,b);//RGB(r,g,b);
fd.csName = name;
fd.csName = fd.csName.trimmed();//.Trim();
fd.bDraw = 0;
m_FracDefList.append(fd);
if ( feof(fp))
break;
}
fclose(fp);
}
else
{
sprintf(name,"打开裂缝参数配置文件错误:%s!",str);
QMessageBox::information(nullptr, "读取文件失败", name);
}
}
void FormDraw::Refurbish()
{
// if we are in the valid range for the property
// set the new property value
// update the property
// let the control know that the property has changed
// if(this->m_bTableData)
// {
// this->ReadData();//read table
// }
// else
// {
// this->ReadData(m_csCurveDDIR,0,&m_Curve);
// this->ReadData(m_csCurveDANG,1,&m_Curve2);
// this->ReadData(m_csCurveGrad,2,&m_Curve3);
// }
// redraw the control
}
//曲线
//read curve
void FormDraw::ReadData(QString strSlfName, QString strLineName, int iCurve, Slf_CURVE *curve)
{
//
if(strSlfName.isEmpty())
{
return;
}
// 读曲线数值
CMemRdWt mrw;
m_PointNum = 0 ;
if ( iCurve== 0 )
{
if(m_Value) delete []m_Value;
m_Value = 0;
}
if ( iCurve== 1 )
{
if(m_Value2) delete []m_Value2;
m_Value2 = 0;
}
if ( iCurve== 2 )
{
if(m_Value3) delete []m_Value3;
m_Value3 = 0;
}
DWORD byte;
//CString wellname(sFilePath);
if ( mrw.Open(strSlfName.toStdString().c_str()) ) // 打开井文件
{
int iIndex=mrw.OpenCurve(strLineName.toStdString().c_str());
if (iIndex >= 0)
{
mrw.GetCurveInfo(iIndex,curve);
if(curve->DepLevel==0) return;
m_PointNum = (float)(fabs((curve->EndDepth - curve->StartDepth)/curve->DepLevel+0.5));
m_SDep=curve->StartDepth;
m_EDep=curve->EndDepth;
m_Rlev=curve->DepLevel;
if ( iCurve== 0 )
{
m_Value=new char[m_PointNum*curve->CodeLen+4];
if(m_Value)
{
byte = mrw.ReadCurve(iIndex,m_SDep,m_PointNum,(void *)m_Value);
}
}
else
{
if ( iCurve == 1 )
{
m_Value2=new char[m_PointNum*curve->CodeLen+4];
if(m_Value2){
byte = mrw.ReadCurve(iIndex,m_SDep,m_PointNum,(void *)m_Value2);
}
}
else
{
m_Value3=new char[m_PointNum*curve->CodeLen+4];
if(m_Value3){
byte = mrw.ReadCurve(iIndex,m_SDep,m_PointNum,(void *)m_Value3);
}
}
}
mrw.CloseCurve(iIndex);
}
mrw.Close(); //关闭井文件
}
}
//表格
//for table dip ,read FRAC_HOLE.TABLE
void FormDraw::ReadData(QString strSlfName, QString strLineName)
{
QString cs;
int nField,len;
FRAC_TABLE frac;
CMemRdWt mrw;
m_PointNum = 0 ;
char strFracTable[256];
int i,j,iIndex,nCount,iType=1;
char wellname2[512];
char *buffer;
Slf_TABLE_FIELD *Table_Field;
char bufField[1024];
float val;
//
m_FracTabList.clear();
if(m_qsTable=="AC"|| m_qsTable=="")
{
m_qsTable="FRAC_HOLE.TABLE";
}
//
if(strSlfName.isEmpty())
{
return;
}
//CString wellname(strSlfName);
if ( mrw.Open(strSlfName.toStdString().c_str()) ) // 打开井文件
{
//CString strFracTable(m_qsTable);
iIndex = mrw.OpenTable(m_qsTable.toStdString().c_str());
if (iIndex >= 0)
{
nField = mrw.GetTableFieldCount(iIndex);
Table_Field = new Slf_TABLE_FIELD[nField+1];
// 读取字段信息
mrw.GetTableFieldInfo(iIndex, Table_Field);
// 读取数据记录
nCount = mrw.GetTableRecordCount(iIndex);
i = mrw.GetTableRecordLength(iIndex);
buffer = new char[i+2];
m_PointNum = nCount;
for(i=0; i<nCount; i++)
{
memset(&frac, 0x00, sizeof(FRAC_TABLE));
mrw.ReadTable(iIndex, i+1, buffer);
frac.DEP = -9999;
len = 0;
for(j=0; j<nField; j++)
{
val = GetData(Table_Field[j].RepCode, &buffer[len]);
cs = Table_Field[j].Name;
if ( m_qsDepth.compare(cs)==0)
frac.DEP = val;
if ( m_qsDIP.compare(cs)==0)
frac.DIPorS = val;
if ( m_qsDIR.compare(cs)==0)
frac.DIR = val;
if ( m_qsID.compare(cs)==0)
frac.ID = (int)(val);
len += Table_Field[j].Length;
}
m_FracTabList.append(frac);
}
delete [] Table_Field;
delete [] buffer;
mrw.CloseTable(iIndex);
}
mrw.Close(); //关闭井文件
}
}
void FormDraw::addRandomGraph(QMyCustomPlot *widget, QVector<double> x, QVector<double> y, QString strSlfName, QString strLineName, QString strAliasName, QString strUnit,
double newLeftScale, double newRightScale, QString strScaleType, QColor newlineColor, double width, Qt::PenStyle lineStyle)
{
widget->addRandomGraph(x, y, strSlfName, strLineName, strAliasName, strUnit,
newLeftScale, newRightScale, strScaleType, newlineColor, width, lineStyle);
//道-对象
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_vmax, m_vmin, strScaleType, "curveObject");
2025-10-29 17:23:30 +08:00
//AppendConsole(PAI_INFO, "FormDraw addRandomGraph");
// widget->addGraph();
// if(strLineName=="")
// {
// strLineName = QString("曲线 %1").arg(widget->graphCount());
// }
// widget->graph()->setName(strLineName);
// //禁用自动重绘:在大量数据更新前禁用自动重绘
// //widget->setNotAntialiasedElements(QCP::aeAll);
// widget->graph()->setData(x, y);
// if(newLeftScale!=-9999)
// {
// widget->graph()->setLineStyle((QCPGraph::LineStyle)(lineStyle));//曲线
2025-10-29 17:23:30 +08:00
// widget->graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(1)));
2025-10-29 17:23:30 +08:00
// QPen graphPen;
// graphPen.setColor(newlineColor);
// graphPen.setWidthF(width);
// graphPen.setStyle(lineStyle);//实线
// widget->graph()->setPen(graphPen);
// }
// else
// {
// widget->graph()->setLineStyle((QCPGraph::LineStyle)(1));//曲线
2025-10-30 11:55:37 +08:00
// widget->graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(1)));
// // widget->graph()->setScatterStyle(QCPScatterStyle(QPixmap(":/image/file.png")));
// //widget->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 5));
2025-10-30 11:55:37 +08:00
// QPen graphPen;
// newlineColor = QColor(std::rand()%245+10, std::rand()%245+10, std::rand()%245+10);
// graphPen.setColor(newlineColor);
// width = 2;
// graphPen.setWidthF(width);
// graphPen.setStyle(Qt::SolidLine);//实线
// widget->graph()->setPen(graphPen);
// //widget->replot();
// }
// //道-对象
// m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_vmax, m_vmin, strScaleType);
//AppendConsole(PAI_INFO, "FormDraw addRandomGraph end");
2025-10-29 17:23:30 +08:00
}
void FormDraw::dragEnterEvent(QDragEnterEvent* event)
{
qDebug() << "FormDraw dragEnterEvent";
const QMimeData* mimeData = event->mimeData();
// 检查拖拽的数据类型,确定是否接受拖拽
if (event->mimeData()->hasFormat("text/plain")) {
event->acceptProposedAction();
//QApplication::setOverrideCursor(Qt::PointingHandCursor); // 设置鼠标为可添加状态
}
else
{
event->ignore();
//QApplication::setOverrideCursor(Qt::ForbiddenCursor); // 设置鼠标为不可添加状态
2025-10-29 17:23:30 +08:00
}
}
void FormDraw::dragMoveEvent(QDragMoveEvent* event)
{
//qDebug() << "FormDraw dragMoveEvent";
2025-10-29 17:23:30 +08:00
// 可以在这里更新鼠标的位置,根据位置判断是否可以放置
// ...
//dragEnterEvent(event); // 可以使用相同的逻辑
//event->accept();
}
void FormDraw::dropEvent(QDropEvent* event)
{
qDebug() << "FormDraw dropEvent";
// 处理放置动作更新UI或数据
if (event->mimeData()->hasFormat("text/plain")) {
// 获取拖拽的数据
QString strExtern = event->mimeData()->text();
qDebug() << strExtern;
//
QStringList list = strExtern.split("#@@#");//QString字符串分割函数
if (list.size() > 3)
2025-10-29 17:23:30 +08:00
{
QString strSlfName = list[0];
QString strWellName = list[1];
QString strLineName = list[2];
QString strType = list[3];
2025-10-29 17:23:30 +08:00
qDebug() << "strSlfName:" << strSlfName<< " strWellName:" << strWellName << " strLineName:" << strLineName << " strType:" << strType;
2025-10-29 17:23:30 +08:00
if(m_strWellName == strWellName)
{
if(strType=="curveObject")
{
//新建曲线
emit CallManage::getInstance()->sig_AddLine(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
}
else if(strType=="waveObject")
{
//新建波列
emit CallManage::getInstance()->sig_AddWave(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
}
else if(strType=="tableObject")
{
//新建表格曲线
emit CallManage::getInstance()->sig_AddTableLine(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
}
2025-10-29 17:23:30 +08:00
// 接受拖拽事件
event->setDropAction(Qt::MoveAction);
event->accept();
}
else
{
// 如果井名不正确,不接受拖拽事件
event->ignore();
}
}
else
{
// 如果数据格式不正确,不接受拖拽事件
event->ignore();
2025-10-29 17:23:30 +08:00
}
}
else
{
// 如果数据格式不正确,不接受拖拽事件
event->ignore();
}
// 恢复鼠标光标
//QApplication::restoreOverrideCursor();
}