📄 seistracedata.cpp
字号:
// SeisTraceData.cpp: implementation of the CSeisTraceData class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "WellDataProcess.h"
#include "SeisTraceData.h"
#include "GlobalData.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CSeisTraceData::CSeisTraceData()
{
m_nMargin = 10;
m_nHeadHeight = 60;
}
CSeisTraceData::~CSeisTraceData()
{
}
void CSeisTraceData::InitVariation(COLORREF corCurve, int nCurveWidth, int nCurveStyle, \
int nXBase, int nYBase, int nColWidth, int nColHeight, int nMargin)
{
m_corCurve = corCurve;
m_nCurveWidth = nCurveWidth;
m_nCurveStyle = nCurveStyle;
m_nXBase = nXBase;
m_nYBase = nYBase;
m_nColWidth = nColWidth;
m_nColHeight = nColHeight;
m_nMargin = nMargin;
}
void CSeisTraceData::Draw(CDC *pDC)
{
DrawScale(pDC);
CPen pen;
pen.CreatePen(m_nCurveStyle, m_nCurveWidth, m_corCurve);
CPen *pOldPen = pDC->SelectObject(&pen);
int nDataNum = m_arrPoint.GetSize();
if(nDataNum == 0)
return;
int x0, y0;
int x, y;
int i, j, k;
float fScaleY = float(m_nColHeight - m_nHeadHeight) / (nDataNum + 1);
float fScaleX = 30.0 / (m_fDataMax - m_fDataMin);
int xbase, ybase;
float* pPoint = new float[m_nColHeight - m_nHeadHeight];
for ( i = 0; i < m_nColHeight - m_nHeadHeight; i ++)
pPoint[i] = 0.0;
for(i = 0; i < nDataNum - 1; i ++)
{
float fAmp1 = m_arrPoint[i];
float fAmp2 = m_arrPoint[i + 1];
for(k = 0; k <=(int)(fScaleY+0.5); k ++) // 计算各相素点的值。
{
int nIndex = int(i * fScaleY + k + 0.5f);
pPoint[nIndex] = int (fAmp1 + k * (fAmp2 - fAmp1) / fScaleY + 0.5f);
}
}
for(j = 0; j < 30; j ++)
{
CString str;
xbase = m_nXBase + 10 * j + m_nMargin;
ybase = m_nYBase + m_nHeadHeight;
x0 = xbase + pPoint[0] * fScaleX;
y0 = ybase;
str.Format("%d", j + 1);
PutText(1, x0, y0 - 12, 12, 0, str, pDC);
for(i = 1; i < m_nColHeight - m_nHeadHeight; i ++)
{
pDC->MoveTo(x0, y0);
x = xbase + pPoint[i] * fScaleX;
y = ybase + i;
pDC->LineTo(x, y);
if(pPoint[i] > 0)
{
pDC->LineTo(xbase, y);
}
x0 = x;
y0 = y;
}
}
pDC->SelectObject(pOldPen);
delete [] pPoint;
}
void CSeisTraceData::DrawScale(CDC *pDC)
{
CRect rc;
rc.top = m_nYBase;
rc.left = m_nXBase;
rc.right = m_nXBase + m_nColWidth;
rc.bottom = m_nYBase + m_nColHeight;
PutText(1, rc.left + rc.Width() / 2, rc.top + 10, 16, 0, "Traces", pDC);
CPen pen;
pen.CreatePen(PS_SOLID, 2, RGB(255, 255, 255));
CPen *pOldPen = pDC->SelectObject(&pen);
pDC->MoveTo(rc.left + 10, rc.top + m_nHeadHeight);
pDC->LineTo(rc.right - 10, rc.top + m_nHeadHeight);
pDC->SelectObject(pOldPen);
DrawRect(pDC, rc, COR_BLUE);
}
void CSeisTraceData::AddSynPointData(float fValue)
{
m_arrSynPoint.Add(fValue);
}
void CSeisTraceData::DrawSynthData(CDC *pDC)
{
CPen pen;
pen.CreatePen(m_nCurveStyle, m_nCurveWidth, m_corCurve);
CPen *pOldPen = pDC->SelectObject(&pen);
int nDataNum = m_arrSynPoint.GetSize();
if(nDataNum == 0)
return;
int x0, y0;
int x, y;
int i, j, k;
float fScaleY = float(m_nColHeight - m_nHeadHeight) / (nDataNum + 1);
float fScaleX = 30.0 / (m_fDataMax - m_fDataMin);
int xbase, ybase;
float* pPoint = new float[m_nColHeight - m_nHeadHeight];
for ( i = 0; i < m_nColHeight - m_nHeadHeight; i ++)
pPoint[i] = 0.0;
for(i = 0; i < nDataNum - 1; i ++)
{
float fAmp1 = m_arrSynPoint[i];
float fAmp2 = m_arrSynPoint[i + 1];
for(k = 0; k <=(int)(fScaleY+0.5); k ++) // 计算各相素点的值。
{
int nIndex = int(i * fScaleY + k + 0.5f);
pPoint[nIndex] = int (fAmp1 + k * (fAmp2 - fAmp1) / fScaleY + 0.5f);
}
}
CString str;
xbase = m_nXBase + 10 * j + m_nMargin;
ybase = m_nYBase + m_nHeadHeight;
x0 = xbase + pPoint[0] * fScaleX;
y0 = ybase;
str.Format("%d", j + 1);
PutText(1, x0, y0 - 12, 12, 0, str, pDC);
for(i = 1; i < m_nColHeight - m_nHeadHeight; i ++)
{
pDC->MoveTo(x0, y0);
x = xbase + pPoint[i] * fScaleX;
y = ybase + i;
pDC->LineTo(x, y);
if(pPoint[i] > 0)
{
pDC->LineTo(xbase, y);
}
x0 = x;
y0 = y;
}
pDC->SelectObject(pOldPen);
delete [] pPoint;
}
void CSeisTraceData::ClearData()
{
m_arrPoint.RemoveAll();
m_arrSynPoint.RemoveAll();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -