264 lines
7.1 KiB
C++
264 lines
7.1 KiB
C++
#include <math.h>
|
|
#include <cassert>
|
|
#include <QApplication>
|
|
#include <QDebug>
|
|
#include "MemRdWt.h"
|
|
#include "DrawFac.h"
|
|
#include <qdatetime.h>
|
|
#include "geometryutils.h"
|
|
|
|
CDrawFac::CDrawFac(QMyCustomPlot *myCustomPlot, QString strSlfName, QString csCurve)
|
|
{
|
|
m_myCustomPlot = myCustomPlot;
|
|
|
|
//隐藏刻度
|
|
myCustomPlot->xAxis->setTicks(false);
|
|
myCustomPlot->yAxis->setTicks(false);
|
|
myCustomPlot->xAxis2->setTicks(false);
|
|
myCustomPlot->yAxis2->setTicks(false);
|
|
|
|
//画2条竖线
|
|
int iMyWidth = myCustomPlot->axisRect(0)->width();
|
|
QCPItemStraightLine *qcpItemLine = new QCPItemStraightLine(myCustomPlot);
|
|
qcpItemLine->point1->setCoords(-1, iMyWidth/2);//位置
|
|
qcpItemLine->point2->setCoords(-2, iMyWidth/2);//位置
|
|
//qcpItemLine->setPen(pPenStraightLine);
|
|
|
|
QCPItemStraightLine *qcpItemLine2 = new QCPItemStraightLine(myCustomPlot);
|
|
qcpItemLine2->point1->setCoords(-1, 3*iMyWidth/4);//位置
|
|
qcpItemLine2->point2->setCoords(-2, 3*iMyWidth/4);//位置
|
|
|
|
ReadFracDef();
|
|
|
|
ReadData(strSlfName, csCurve);
|
|
DrawFac(1);//相
|
|
DrawFac(2);//亚相
|
|
}
|
|
|
|
CDrawFac::~CDrawFac(void)
|
|
{
|
|
m_FracDef.clear();
|
|
m_ObjList.clear();
|
|
}
|
|
|
|
void CDrawFac::ReadFracDef()
|
|
{
|
|
m_FracDef.clear();
|
|
|
|
QString fracFilePath = GetConfPath() + "GEoFac.ini";
|
|
|
|
//
|
|
FAC_DEF fd;
|
|
char str[512],fac[512],phase[64],mFac[64];
|
|
int r,g,b,id;
|
|
FILE *fp;
|
|
QString qs;
|
|
fp = fopen(fracFilePath.toStdString().c_str(), "r");
|
|
if ( fp != nullptr )
|
|
{
|
|
fgets(str,256,fp); // 跳过第一行
|
|
while (!feof(fp))
|
|
{
|
|
fgets(str,256,fp);
|
|
qs = str;
|
|
qs.trimmed();
|
|
if (qs.length() < 8) break ;
|
|
//代码 微相 亚相 相
|
|
sscanf(str,"%d %s %s %s",&fd.iCode,mFac,phase,fac);
|
|
fd.mFac = mFac;
|
|
fd.Fac = fac;
|
|
fd.Phase = phase;
|
|
m_FracDef.append(fd);
|
|
if ( feof(fp))
|
|
break;
|
|
}
|
|
fclose(fp);
|
|
}
|
|
else
|
|
{
|
|
sprintf(fac,"打开沉积相参数配置文件错误:%s!",str);
|
|
QMessageBox::information(nullptr, "读取文件失败", fac);
|
|
}
|
|
}
|
|
|
|
void CDrawFac::ReadData(QString strSlfName, QString csCurve)
|
|
{
|
|
if(strSlfName.isEmpty()) return;
|
|
//清空
|
|
m_ObjList.clear();
|
|
|
|
QString cs;
|
|
int nLineWidth=2;
|
|
int nField;
|
|
QColor crColor(255,0,0);
|
|
FAC_TABLE frac;
|
|
CMemRdWt mrw;
|
|
char strFracTable[256];
|
|
int i,j,iIndex,nCount,iType=1;
|
|
|
|
if (mrw.Open(strSlfName.toStdString().c_str()) ) // 打开井文件
|
|
{
|
|
iIndex=mrw.OpenTable(csCurve.toStdString().c_str());
|
|
if(iIndex>=0)
|
|
{
|
|
nField=mrw.GetTableFieldCount(iIndex);
|
|
nCount=mrw.GetTableRecordCount(iIndex);
|
|
cs ="";
|
|
if ( nField != 7 )
|
|
nCount = 0;
|
|
for(i=0;i<nCount;i++)
|
|
{
|
|
mrw.ReadTable(iIndex,i+1,(void*)&frac);
|
|
m_ObjList.append(frac);
|
|
|
|
//显示文本
|
|
m_myCustomPlot->addMFacToPlot(-frac.edep, -frac.sdep, QString::fromLocal8Bit(frac.mFac));
|
|
}
|
|
mrw.CloseTable(iIndex);
|
|
}
|
|
mrw.Close(); //关闭井文件
|
|
}
|
|
}
|
|
|
|
void CDrawFac::DrawFac(int iType)
|
|
{
|
|
int j;
|
|
float dep1,dep2;
|
|
float top,bottom;
|
|
QString str1,str2;
|
|
QColor crColor(0,0,0);
|
|
QPen qPen(crColor, 1, Qt::SolidLine);
|
|
if ( m_ObjList.count()<2 )
|
|
return ;
|
|
|
|
//绘制相、亚相
|
|
FAC_TABLE pObj;
|
|
pObj =m_ObjList[0];
|
|
if (iType==1)
|
|
str1 = QString::fromLocal8Bit(pObj.Fac);
|
|
else
|
|
str1 = QString::fromLocal8Bit(pObj.Phase);
|
|
str1.trimmed();
|
|
top = pObj.sdep;
|
|
|
|
for (j=1;j<m_ObjList.count(); j++)
|
|
{
|
|
pObj =m_ObjList[j];
|
|
|
|
if (iType==1)
|
|
str2= QString::fromLocal8Bit(pObj.Fac);
|
|
else
|
|
str2 = QString::fromLocal8Bit(pObj.Phase);
|
|
str2.trimmed();
|
|
|
|
if (str2!=str1 || j==(m_ObjList.count()-1))
|
|
{
|
|
if ( j==(m_ObjList.count()-1))
|
|
bottom = m_ObjList[j].edep;
|
|
else
|
|
bottom = m_ObjList[j-1].edep;
|
|
|
|
|
|
//显示文本
|
|
if (iType==1)
|
|
{
|
|
//相
|
|
m_myCustomPlot->addFacToPlot(-bottom, -top, str1);
|
|
}
|
|
else
|
|
{
|
|
//亚相
|
|
m_myCustomPlot->addPhaseToPlot(-bottom, -top, str1);
|
|
}
|
|
|
|
top = pObj.sdep;
|
|
str1=str2;
|
|
}
|
|
}
|
|
}
|
|
|
|
//void CDrawFac::DrawFrac(QPainter* pDC,QRectF mrt)
|
|
//{
|
|
// QRectF rt;
|
|
// float flDepthScale = m_DepthScale*m_nVertRatio;
|
|
// float sdepc,edepc,sdep,edep;
|
|
// float temp,temp2;
|
|
// CFracObj *pObj;
|
|
// QString cs;
|
|
// int i,j,n,nCol=2;
|
|
// QColor crColor(0,0,0);
|
|
// QPen qPen(crColor, 1, Qt::SolidLine);
|
|
// rt=mrt;
|
|
// flDepthScale = m_DepthScale*m_nVertRatio;
|
|
// rt = mrt;
|
|
// // 计算显示深度
|
|
// GetDepth(pDC,mrt,rt,sdep,edep,sdepc,edepc);
|
|
|
|
// if ( edep > m_PlotEdep ) edep = m_PlotEdep;
|
|
// if ( sdep < m_PlotSdep ) sdep = m_PlotSdep;
|
|
// if ( sdep > m_PlotEdep ) return ;
|
|
// if ( edep < m_PlotSdep ) return ;
|
|
// if ( edep > m_PlotEdep ) edep = m_PlotEdep;
|
|
// pDC->setBrush(Qt::NoBrush);
|
|
// pDC->setFont(m_LabelFont);
|
|
|
|
// if ( m_bDrawFac)
|
|
// nCol++;
|
|
// if ( m_bDrawPhase)
|
|
// nCol++;
|
|
// n = m_FracDef.count();
|
|
// pDC->setPen(qPen);
|
|
// //绘制微相
|
|
// for (j=0;j<m_ObjList.count(); j++)
|
|
// {
|
|
// pObj =m_ObjList[j];
|
|
// CalQRectF(pObj,mrt,sdep,flDepthScale);
|
|
// if ( pObj->m_Frac.edep <sdep || pObj->m_Frac.sdep > edep)
|
|
// continue;
|
|
// rt= pObj->m_Rect;
|
|
// temp = mrt.left()+2.*mrt.width()/nCol;
|
|
// rt.setRight(temp);
|
|
// if (m_bSymbol) //绘制微相符号
|
|
// pObj->Draw(pDC,rt,m_iMode);
|
|
// if ( m_bDrawMFac )
|
|
// {
|
|
// cs = pObj->m_Frac.mFac;
|
|
// pDC->drawText(rt,Qt::AlignCenter| Qt::AlignVCenter,cs);
|
|
// }
|
|
// pDC->drawLine(QPoint(mrt.left(),rt.top()),QPoint(temp,rt.top()));
|
|
// pDC->drawLine(QPoint(mrt.left(),rt.bottom()),QPoint(temp,rt.bottom()));
|
|
// }
|
|
// if ( m_bDrawFac && m_bDrawPhase)
|
|
// {
|
|
// temp = mrt.left()+2.*mrt.width()/nCol;
|
|
// temp2 = mrt.left()+3.*mrt.width()/nCol;
|
|
// DrawFac(pDC,mrt,2,temp,temp2);
|
|
// DrawFac(pDC,mrt,1,temp2,mrt.right());
|
|
// pDC->drawLine(QPoint(temp,mrt.top()),QPoint(temp,mrt.bottom()));
|
|
// pDC->drawLine(QPoint(temp2,mrt.top()),QPoint(temp2,mrt.bottom()));
|
|
// }
|
|
// else
|
|
// {
|
|
// if ( m_bDrawFac || m_bDrawPhase)
|
|
// {
|
|
// temp = mrt.left()+2.*mrt.width()/nCol;
|
|
// if ( m_bDrawFac )
|
|
// DrawFac(pDC,mrt,1,temp,mrt.right());
|
|
// else
|
|
// DrawFac(pDC,mrt,2,temp,mrt.right());
|
|
// pDC->drawLine(QPoint(temp,mrt.top()),QPoint(temp,mrt.bottom()));
|
|
// }
|
|
// }
|
|
// // 绘制边框
|
|
// if ( m_selection.count() > 0 )
|
|
// {
|
|
// CFracObj *pObj = m_selection[0];
|
|
// if (pObj->m_bSelected !=0 )
|
|
// {
|
|
// CalQRectF(pObj,mrt,sdep,flDepthScale);
|
|
// pObj->DrawTracker(pDC,selected,1);
|
|
// }
|
|
// }
|
|
//}
|
|
|