logplus/logPlus/formlogmud.cpp
DESKTOP-450PEFP\mainc 502043d81e 修改波列道修改道宽,绘图填充问题。
修改波列道修改深度比例尺绘制问题,缩放绘图问题
修改算法执行完毕后,更新左侧树更新可视解释绘图逻辑
2026-06-26 17:54:51 +08:00

315 lines
8.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "formlogmud.h"
#include "ui_formlogmud.h"
#include <QPainter>
#include "CallManage.h"
#include "MemRdWt.h"
FormLogmud::FormLogmud(QWidget *parent, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName) :
QWidget(parent),
ui(new Ui::FormLogmud)
{
ui->setupUi(this);
m_strSlfName = strSlfName;
m_strWellName = strWellName;
m_strTrackName = strTrackName;
m_strLineName = strLineName;
m_pLogMud = new LogmudItemDrawer();
LoadFromSLF_LogMud();
m_parent = parent;
//自定义滚动条
connect(CallManage::getInstance(), SIGNAL(sig_vertScrollBarChanged_setGeometry(QString, double, double, double, double)), this, SLOT(vertScrollBarChanged_setGeometry(QString, double, double, double, double)));
//打印
connect(CallManage::getInstance(), SIGNAL(sig_vertScrollBarChanged_santu_Print(QString, int, int)), this, SLOT(vertScrollBarChanged_Print(QString, int, int)));
connect(CallManage::getInstance(), SIGNAL(sig_ResizeDepth(QString, int, float, float)), this, SLOT(s_ResizeDepth(QString, int, float, float)));
}
void FormLogmud::DrawTvd()
{
// //
// 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)
// CDrawTvd *drawTvd = new CDrawTvd();
// drawTvd->sFilePath = m_strSlfName;
// drawTvd->DrawTvd(&painter, rect);
}
FormLogmud::~FormLogmud()
{
delete ui;
}
bool FormLogmud::LoadFromSLF_LogMud()
{
this->m_childrenItems.clear();
CMemRdWt *logio = new CMemRdWt();
if (!logio->Open(m_strSlfName.toStdString().c_str(), CSlfIO::modeRead))
{
delete logio;
return false;
}
int iIndex = logio->OpenTable(m_strLineName.toStdString().c_str());
if (iIndex < 0)
return false;
int count1 = logio->GetTableRecordCount(iIndex);
int len = logio->GetTableRecordLength(iIndex);
if (m_LogMun)
delete m_LogMun;
m_LogMun = new struct logmud_stru[count1];
for (int i = 0; i < count1; i++)
{
logio->ReadTable(iIndex, i + 1, &m_LogMun[i]);
}
iIndex = logio->OpenTable("LOGMUD_DATA");
if (iIndex > -1) {
int count = logio->GetTableRecordCount(iIndex);
int len = logio->GetTableRecordLength(iIndex);
logio->IsChange = true;
logmud_result_stru pLogmud;
int n = 0;
for (int i = 0; i < count; i++)
{
logio->ReadTable(iIndex, i + 1, &pLogmud);
double top = pLogmud.depth;
double bottom = pLogmud.depth;
LogmudResultItem* pResult = AddItem(top, bottom);
if (pResult) {
pResult->Order = i;
pResult->depth = pLogmud.dep;
pResult->Number = pLogmud.depth;
pResult->type = pLogmud.type;
// pResult->BH=valy;
// pResult->WH=valx;
bool matchedLogmud = false;
for (int j = 0; j < count1; j++) {
if (qAbs(m_LogMun[j].DEPTH - pResult->depth) < 1e-4f)
{
pResult->CoreValues = m_LogMun[j];
matchedLogmud = true;
break;
}
}
// 对数图版(type=2)的WH/BH不落盘加载时重算并进行安全截断避免极值导致绘制卡死。
if (matchedLogmud&&qAbs(pResult->type - 2.0f) < 0.5f)
{
float safeC1 = qAbs(pResult->CoreValues.C1);
if (!IsFiniteNumber(safeC1) || safeC1 < 1e-6f) safeC1 = 1e-6f;
float valx = (pResult->CoreValues.C2 / safeC1)*1000.0f;
float valy = (pResult->CoreValues.C3 / safeC1)*1000.0f;
if (!IsFiniteNumber(valx) || valx <= 0.0f) valx = 1.0f;
if (!IsFiniteNumber(valy) || valy <= 0.0f) valy = 1.0f;
if (valx > 1000000.0f) valx = 1000000.0f;
if (valy > 1000000.0f) valy = 1000000.0f;
pResult->WH = valx;
pResult->BH = valy;
}
}
}
}
delete logio;
return true;
}
LogmudResultItem* FormLogmud::AddItem(double topDepth, double bottomDepth)
{
int insertPos = GetInsertIndex(topDepth, bottomDepth);
if (insertPos != -1)
{
return this->AddItem(topDepth, bottomDepth, insertPos);
}
else
{
//OutputErrorInfo();
}
return NULL;
}
LogmudResultItem *FormLogmud::AddItem(double topDepth, double bottomDepth, int insertPos)
{
if (topDepth == -9999 || bottomDepth == -9999.0) return NULL;
LogmudResultItem* newItem = new LogmudResultItem();
if (newItem != NULL)
{
newItem->SetTopDepth(topDepth);
newItem->SetBottomDepth(bottomDepth);
m_childrenItems.insert(insertPos, newItem);
return newItem;
}
return NULL;
}
int FormLogmud::GetInsertIndex(double topDepth, double bottomDepth) const
{
LogmudResultItem curItem(topDepth, bottomDepth);
int topIndex = 0;
int bottomIndex = m_childrenItems.size();
if (bottomIndex == 0)
{
return 0;
}
int mid = (bottomIndex + topIndex) / 2;
while (topIndex <= bottomIndex && mid < m_childrenItems.size())
{
if (m_childrenItems[mid]->Contains(topDepth)) {
return -1;
}
if (m_childrenItems[mid]->Contains(bottomDepth))
{
return -1;
}
if (*m_childrenItems[mid] < curItem)
{
topIndex = mid + 1;
}
else if (*m_childrenItems[mid] > curItem)
{
bottomIndex = mid - 1;
}
else
{
if (*m_childrenItems[mid] == curItem)
{
return -1;
}
//相交了,非法输入
if ((bottomDepth - topDepth) / 2 + topDepth > (*m_childrenItems[mid]).GetTopDepth() &&
(bottomDepth - topDepth) / 2 + topDepth < (*m_childrenItems[mid]).GetBottomDepth())
return -1;
else return mid + 1;
}
mid = (bottomIndex + topIndex) / 2;
}
if (mid < m_childrenItems.size() && *m_childrenItems[mid] < curItem)
{
return mid + 1;//目前算法有漏洞,临时修改一下
}
return mid;
}
void FormLogmud::setDepthY(float fy1, float fy2)
{
m_wellTop = qAbs(fy2);
}
void FormLogmud::updateDepthY(float fy1, float fy2)
{
m_wellTop = qAbs(fy2);
}
void FormLogmud::initBottomDepth(double dep)
{
m_dBottomDepth = qAbs(dep);
m_dAddY = (m_dBottomDepth - m_dTopDepth) * m_nbb;
}
void FormLogmud::paintEvent(QPaintEvent*)
{
//
QPainter painter(this);
QRect rect = this->rect();
// QRect rect = m_parent->rect();
//背景透明
painter.fillRect(rect.left(), rect.top(), rect.width(), rect.height(), QColor(0, 0, 0, 0)); //QColor(67, 67, 67, 100)
for (int i = 0; i < m_childrenItems.size(); i++)
{
LogmudResultItem* pItem = m_childrenItems.at(i);
//if (pItem->type == 1)
{
float top = pItem->GetTopDepth();
float bottom = pItem->GetBottomDepth();
double dTmpBotm = (m_dTopDepth + m_dAddY);
if (bottom < m_dTopDepth - 1) continue;
if (top > dTmpBotm + 1) continue;
double ddep = m_wellTop - m_dTopDepth;
QRectF itemBoundingRect(0, top + ddep/*+Rlev*/, rect.width(), bottom - top);
m_pLogMud->DrawItem(&painter, pItem, itemBoundingRect, false);
break;
}
}
}
void FormLogmud::s_ResizeDepth(QString strUuid, int nHeight, float fDepthUpperY, float fDepthLowerY)
{
if (m_strUuid != strUuid)
return;
//m_fTopY = qAbs(fDepthUpperY);
//this->setFixedHeight(nHeight*m_nbb);
m_dBottomDepth = qAbs(fDepthLowerY);
m_dAddY = (m_dBottomDepth - m_dTopDepth) * m_nbb;
}
void FormLogmud::vertScrollBarChanged_setGeometry(QString strUuid, double value, double low, double upper, double ddepth)
{
if (m_strUuid == strUuid)
{
}
else
{
return;
}
m_dTopDepth = ddepth;
update();
}
//自定义滚动条
// void FormLogmud::vertScrollBarChanged(QString strUuid, double value, double low, double upper)
// {
// if(m_strUuid==strUuid)
// {
// }
// else
// {
// return;
// }
// m_dTopDepth = value;
// //上移或下移
// QRect geoRect = geometry();
// //
// double dDelta = value - upper;
// double dPercent = dDelta / (low-upper);
//
// setGeometry(0, -(dPercent*geoRect.height()), geoRect.width(), geoRect.height());
// }
//打印
void FormLogmud::vertScrollBarChanged_Print(QString strUuid, int iNum, int iHeightOfScreen)
{
if(m_strUuid==strUuid)
{
}
else
{
return;
}
//上移或下移
QRect geoRect = geometry();
//
double dDelta = iHeightOfScreen*(iNum-1);
setGeometry(0, -dDelta, geoRect.width(), geoRect.height());
}
void FormLogmud::wheelEvent(QWheelEvent *event) // 滚轮事件
{
emit CallManage::getInstance()->sig_mouseWheel(event);
}