优化波列数据绘制方法
This commit is contained in:
parent
1485db1730
commit
c7eb736a6e
|
|
@ -184,8 +184,10 @@ public:
|
||||||
// double x1 = mPlot->xAxis->coordToPixel(dbCenterX);
|
// double x1 = mPlot->xAxis->coordToPixel(dbCenterX);
|
||||||
// double y1 = mPlot->yAxis->coordToPixel(dbCenterY);
|
// double y1 = mPlot->yAxis->coordToPixel(dbCenterY);
|
||||||
// mPixmap->topLeft->setCoords(mPlot->xAxis->pixelToCoord(x1), mPlot->yAxis->pixelToCoord(y1));
|
// mPixmap->topLeft->setCoords(mPlot->xAxis->pixelToCoord(x1), mPlot->yAxis->pixelToCoord(y1));
|
||||||
mPixmap->topLeft->setCoords(right_Hight, lY2);
|
// mPixmap->topLeft->setCoords(right_Hight, lY2);
|
||||||
mPixmap->bottomRight->setCoords(left_Low, lY1);
|
// mPixmap->bottomRight->setCoords(left_Low, lY1);
|
||||||
|
mPixmap->topLeft->setCoords(right_Hight, lY1);
|
||||||
|
mPixmap->bottomRight->setCoords(left_Low, lY2);
|
||||||
drawResult(left_Low, right_Hight, lY1, lY2);
|
drawResult(left_Low, right_Hight, lY1, lY2);
|
||||||
|
|
||||||
// mPixmap->topLeft->setCoords(right_Hight, lY1);
|
// mPixmap->topLeft->setCoords(right_Hight, lY1);
|
||||||
|
|
|
||||||
|
|
@ -263,6 +263,7 @@ void FormDraw::s_addWave(QString strUuid, QString strSlfName, QString strWellNam
|
||||||
|
|
||||||
curv->show();
|
curv->show();
|
||||||
initWave(curv, strSlfName, strWaveName);
|
initWave(curv, strSlfName, strWaveName);
|
||||||
|
//initWave_3D(curv, strSlfName, strWaveName);
|
||||||
connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*)));
|
connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*)));
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
@ -1014,7 +1015,7 @@ double GetData(int RepCode,char *buffer)
|
||||||
void FormDraw::initWave(QMyCustomPlot *widget, QString strSlfName, QString strWaveName)
|
void FormDraw::initWave(QMyCustomPlot *widget, QString strSlfName, QString strWaveName)
|
||||||
{
|
{
|
||||||
CLogIO *logio=new CLogIO();
|
CLogIO *logio=new CLogIO();
|
||||||
logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead);
|
logio->Open(strSlfName.toStdString().c_str(), CSlfIO::modeRead);
|
||||||
//
|
//
|
||||||
int index=logio->OpenWave(strWaveName.toStdString().c_str());
|
int index=logio->OpenWave(strWaveName.toStdString().c_str());
|
||||||
if(index<0) {
|
if(index<0) {
|
||||||
|
|
@ -1118,6 +1119,270 @@ void FormDraw::initWave(QMyCustomPlot *widget, QString strSlfName, QString strWa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 添加色标:
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
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个主刻度
|
||||||
|
|
||||||
|
//对调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);
|
QCPColorScale *colorScale = new QCPColorScale(widget);
|
||||||
|
|
@ -1160,9 +1425,10 @@ void FormDraw::initWave(QMyCustomPlot *widget, QString strSlfName, QString strWa
|
||||||
QString strScaleType = "";
|
QString strScaleType = "";
|
||||||
//道-对象
|
//道-对象
|
||||||
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strWaveName, strAliasName, strUnit, newlineColor, width, _nSamples, 0, strScaleType, "waveObject");
|
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strWaveName, strAliasName, strUnit, newlineColor, width, _nSamples, 0, strScaleType, "waveObject");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void FormDraw::initWave2(QMyCustomPlot *widget, QString strSlfName, QString strWaveName)
|
void FormDraw::initWave2(QMyCustomPlot *widget, QString strSlfName, QString strWaveName)
|
||||||
{
|
{
|
||||||
CLogIO *logio=new CLogIO();
|
CLogIO *logio=new CLogIO();
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,7 @@ public:
|
||||||
|
|
||||||
//波列
|
//波列
|
||||||
void initWave(QMyCustomPlot *widget, QString strSlfName, QString strWaveName);
|
void initWave(QMyCustomPlot *widget, QString strSlfName, QString strWaveName);
|
||||||
|
void initWave_3D(QMyCustomPlot *widget, QString strSlfName, QString strWaveName);
|
||||||
void initWave2(QMyCustomPlot *widget, QString strSlfName, QString strWaveName);
|
void initWave2(QMyCustomPlot *widget, QString strSlfName, QString strWaveName);
|
||||||
|
|
||||||
//表格曲线
|
//表格曲线
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user