logplus/logPlus/formlogmud.cpp

306 lines
7.8 KiB
C++
Raw Normal View History

2026-05-15 10:00:54 +08:00
#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_ChangeTvdProperty(QString, QString, QString, QString, QString, QString, QString, QVariant)),
this, SLOT(s_ChangeTvdProperty(QString, QString, QString, QString, QString, QString, QString, QVariant)));
//自定义滚动条
connect(CallManage::getInstance(), SIGNAL(sig_vertScrollBarChanged_santuyibiao(QString, double, double, double)), this, SLOT(vertScrollBarChanged(QString, double, double, double)));
//打印
connect(CallManage::getInstance(), SIGNAL(sig_vertScrollBarChanged_santu_Print(QString, int, int)), this, SLOT(vertScrollBarChanged_Print(QString, int, int)));
}
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);
2026-05-15 10:00:54 +08:00
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::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();
if (bottom < m_dTopDepth - 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_ChangeTvdProperty(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName,
QString strGroup, QString strProperty, QVariant variant)
{
if(m_strUuid != strUuid ||
m_strSlfName != strSlfName ||
m_strWellName != strWellName ||
m_strTrackName != strTrackName ||
m_strLineName != strLineName)
{
return;
}
if("通常" == strGroup)
{
}
if("绘制图形对象" == strGroup)
{
}
if("边框线型" == strGroup)
{
if ("线宽" == strProperty)
;
else if ("颜色" == strProperty)
;
}
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);
}