275 lines
7.3 KiB
C++
275 lines
7.3 KiB
C++
// OpExecCERSPTestTdScrollView.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "geomative.h"
|
|
#include "OpExecCERSPTestTdScrollView.h"
|
|
|
|
#include "TdChannel.h"
|
|
#include "RspCETdRecord.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COpExecCERSPTestTdScrollView
|
|
|
|
IMPLEMENT_DYNCREATE(COpExecCERSPTestTdScrollView, CScrollView)
|
|
|
|
COpExecCERSPTestTdScrollView::COpExecCERSPTestTdScrollView()
|
|
{
|
|
m_pTdChannel = NULL;
|
|
|
|
m_fMaxCX = 0.0;
|
|
m_fMaxCY = 0.0;
|
|
m_iCXOffset = 60;
|
|
m_iCYOffset = 40;
|
|
|
|
}
|
|
|
|
COpExecCERSPTestTdScrollView::~COpExecCERSPTestTdScrollView()
|
|
{
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(COpExecCERSPTestTdScrollView, CScrollView)
|
|
//{{AFX_MSG_MAP(COpExecCERSPTestTdScrollView)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COpExecCERSPTestTdScrollView drawing
|
|
|
|
void COpExecCERSPTestTdScrollView::OnInitialUpdate()
|
|
{
|
|
CScrollView::OnInitialUpdate();
|
|
|
|
CSize sizeTotal;
|
|
// TODO: calculate the total size of this view
|
|
sizeTotal.cx = 800;
|
|
sizeTotal.cy = 400;
|
|
|
|
SetScrollSizes(MM_TEXT, sizeTotal);
|
|
|
|
if (NULL != m_pTdChannel)
|
|
{
|
|
this->m_fMaxCX = (float)(m_pTdChannel->m_fMaxR0 * 1.1);
|
|
this->m_fMaxCY = (float)ceil(m_pTdChannel->m_fMaxDepth);
|
|
}
|
|
|
|
// AfxMessageBox("hello");
|
|
}
|
|
|
|
void COpExecCERSPTestTdScrollView::OnDraw(CDC* pDC)
|
|
{
|
|
CDocument* pDoc = GetDocument();
|
|
// TODO: add draw code here
|
|
int iIndex = 0;
|
|
|
|
CBrush brushPt;
|
|
CBrush* pBrushOldPt = NULL;
|
|
|
|
iIndex = 0;
|
|
while (iIndex < m_pTdChannel->m_tdRecArray.GetSize())
|
|
{
|
|
if (((float)VAL_ZERO != ((CRspCETdRecord*)(this->m_pTdChannel->m_tdRecArray.GetAt(iIndex)))->m_fR0) || \
|
|
((float)VAL_ZERO != ((CRspCETdRecord*)(this->m_pTdChannel->m_tdRecArray.GetAt(iIndex)))->m_fI) || \
|
|
((float)VAL_ZERO != ((CRspCETdRecord*)(this->m_pTdChannel->m_tdRecArray.GetAt(iIndex)))->m_fV) || \
|
|
((float)VAL_ZERO != ((CRspCETdRecord*)(this->m_pTdChannel->m_tdRecArray.GetAt(iIndex)))->m_fSP))
|
|
{
|
|
if (NULL != m_pTdChannel)
|
|
{
|
|
this->m_fMaxCX = (float)(m_pTdChannel->m_fMaxR0 * 1.1);
|
|
this->m_fMaxCY = (float)ceil(m_pTdChannel->m_fMaxDepth);
|
|
}
|
|
DrawPoint(m_iCXOffset+CoordinateMapping(((CRspCETdRecord*)(this->m_pTdChannel->m_tdRecArray.GetAt(iIndex)))->m_fR0, m_fMaxCX, 700),
|
|
m_iCYOffset+CoordinateMapping(((CRspCETdRecord*)(this->m_pTdChannel->m_tdRecArray.GetAt(iIndex)))->m_fDepth, m_fMaxCY, 400), pDC, RGB(0x00, 0xFF, 0xFF));
|
|
}
|
|
iIndex++;
|
|
}
|
|
|
|
DrawEX(pDC);
|
|
DrawLY(pDC);
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COpExecCERSPTestTdScrollView diagnostics
|
|
|
|
#ifdef _DEBUG
|
|
void COpExecCERSPTestTdScrollView::AssertValid() const
|
|
{
|
|
CScrollView::AssertValid();
|
|
}
|
|
|
|
void COpExecCERSPTestTdScrollView::Dump(CDumpContext& dc) const
|
|
{
|
|
CScrollView::Dump(dc);
|
|
}
|
|
#endif //_DEBUG
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COpExecCERSPTestTdScrollView message handlers
|
|
|
|
int COpExecCERSPTestTdScrollView::CoordinateMapping(float fValue, float fMappingRange, int MappingFactor)
|
|
{
|
|
float fUnit = 0.0;
|
|
float fMValue = 0.0;
|
|
|
|
fUnit = (float)(fMappingRange / MappingFactor);
|
|
fMValue = fValue / fUnit;
|
|
|
|
return (int)ceilf(fMValue);
|
|
}
|
|
|
|
void COpExecCERSPTestTdScrollView::DrawEX(CDC *const pDC)
|
|
{
|
|
CFont fontEX;
|
|
CFont* pFontOldEX = NULL;
|
|
|
|
CString szLabel = _T("");
|
|
int iIndex = 0;
|
|
|
|
fontEX.CreatePointFont(70, _T("Tahoma"));
|
|
pFontOldEX = pDC->SelectObject(&fontEX);
|
|
|
|
pDC->MoveTo(m_iCXOffset, m_iCYOffset - 10);
|
|
pDC->LineTo(m_iCXOffset + 700, m_iCYOffset - 10);
|
|
|
|
iIndex = 0;
|
|
while (iIndex <= 10)
|
|
{
|
|
pDC->MoveTo(m_iCXOffset + iIndex * (700 / 10), m_iCYOffset - 10);
|
|
pDC->LineTo(m_iCXOffset + iIndex * (700 / 10), m_iCYOffset - 10 - 8);
|
|
|
|
szLabel.Empty();
|
|
szLabel.Format(_T("%.2f"), iIndex * (this->m_fMaxCX / 10));
|
|
|
|
pDC->DrawText(szLabel, CRect(m_iCXOffset + iIndex * (700 / 10) - 15, m_iCYOffset - 10 - 8 - 10, m_iCXOffset + iIndex * (700 / 10) + 15, m_iCYOffset - 10 - 8), DT_SINGLELINE | DT_VCENTER | DT_CENTER);
|
|
|
|
if (10 != iIndex)
|
|
{
|
|
pDC->MoveTo(m_iCXOffset + iIndex * (700 / 10) + 700 / 20, m_iCYOffset - 10);
|
|
pDC->LineTo(m_iCXOffset + iIndex * (700 / 10) + 700 / 20, m_iCYOffset - 10 - 4);
|
|
}
|
|
iIndex++;
|
|
}
|
|
|
|
fontEX.DeleteObject();
|
|
pDC->SelectObject(pFontOldEX);
|
|
|
|
}
|
|
|
|
void COpExecCERSPTestTdScrollView::DrawLY(CDC *const pDC)
|
|
{
|
|
CPen penDot(PS_DOT, 1, RGB(180, 180, 180));
|
|
CPen* pPenOld = NULL;
|
|
|
|
CFont fontEX;
|
|
CFont* pFontOldEX = NULL;
|
|
|
|
CString szLabel = _T("");
|
|
int iIndex = 0;
|
|
|
|
fontEX.CreatePointFont(70, _T("Tahoma"));
|
|
pFontOldEX = pDC->SelectObject(&fontEX);
|
|
|
|
pDC->MoveTo(m_iCXOffset - 10, m_iCYOffset);
|
|
pDC->LineTo(m_iCXOffset - 10, m_iCYOffset + 400);
|
|
|
|
iIndex = 0;
|
|
while (iIndex <= 10)
|
|
{
|
|
pDC->MoveTo(m_iCXOffset - 10, m_iCYOffset + iIndex * (400 / 10));
|
|
pDC->LineTo(m_iCXOffset - 10 - 8, m_iCYOffset + iIndex * (400 / 10));
|
|
|
|
pPenOld = pDC->SelectObject(&penDot);
|
|
pDC->MoveTo(m_iCXOffset - 10, m_iCYOffset + iIndex * (400 / 10));
|
|
pDC->LineTo(m_iCXOffset + 700 + 10, m_iCYOffset + iIndex * (400 / 10));
|
|
pDC->SelectObject(pPenOld);
|
|
|
|
szLabel.Empty();
|
|
szLabel.Format(_T("%.1f"), iIndex * (this->m_fMaxCY / 10));
|
|
|
|
pDC->DrawText(szLabel, CRect(m_iCXOffset - 10 - 8 - 20, m_iCYOffset + iIndex * (400 / 10) - 5, m_iCXOffset - 10 - 8, m_iCYOffset + iIndex * (400 / 10) + 5), DT_SINGLELINE | DT_VCENTER | DT_CENTER);
|
|
|
|
if (10 != iIndex)
|
|
{
|
|
pDC->MoveTo(m_iCXOffset - 10, m_iCYOffset + iIndex * (400 / 10) + 400 / 20);
|
|
pDC->LineTo(m_iCXOffset - 10 - 4, m_iCYOffset + iIndex * (400 / 10) + 400 / 20);
|
|
}
|
|
|
|
iIndex++;
|
|
}
|
|
|
|
pDC->MoveTo(m_iCXOffset + 700 + 10, m_iCYOffset);
|
|
pDC->LineTo(m_iCXOffset + 700 + 10, m_iCYOffset + 400);
|
|
|
|
iIndex = 0;
|
|
while (iIndex <= 10)
|
|
{
|
|
pDC->MoveTo(m_iCXOffset + 700 + 10, m_iCYOffset + iIndex * (400 / 10));
|
|
pDC->LineTo(m_iCXOffset + 700 + 10 + 8, m_iCYOffset + iIndex * (400 / 10));
|
|
|
|
szLabel.Empty();
|
|
szLabel.Format(_T("%.1f"), iIndex * (this->m_fMaxCY / 10));
|
|
|
|
pDC->DrawText(szLabel, CRect(m_iCXOffset + 700 + 10 + 8, m_iCYOffset + iIndex * (400 / 10) - 5, m_iCXOffset + 700 + 10 + 8 + 20, m_iCYOffset + iIndex * (400 / 10) + 5), DT_SINGLELINE | DT_VCENTER | DT_CENTER);
|
|
|
|
if (10 != iIndex)
|
|
{
|
|
pDC->MoveTo(m_iCXOffset + 700 + 10, m_iCYOffset + iIndex * (400 / 10) + 400 / 20);
|
|
pDC->LineTo(m_iCXOffset + 700 + 10 + 4, m_iCYOffset + iIndex * (400 / 10) + 400 / 20);
|
|
}
|
|
|
|
iIndex++;
|
|
}
|
|
|
|
fontEX.DeleteObject();
|
|
pDC->SelectObject(pFontOldEX);
|
|
}
|
|
|
|
CRect COpExecCERSPTestTdScrollView::DrawPoint(int iX, int iY, CDC *const pDC, COLORREF crColor)
|
|
{
|
|
CRect rectClient;
|
|
CRect rectPoint;
|
|
|
|
CBrush brushPt;
|
|
CBrush* pBrushOldPt = NULL;
|
|
|
|
int iTop = 0;
|
|
int iLeft = 0;
|
|
int iBottom = 0;
|
|
int iRight = 0;
|
|
|
|
int iSize = 0;
|
|
|
|
rectPoint.SetRectEmpty();
|
|
|
|
if (NULL != pDC)
|
|
{
|
|
this->GetClientRect(rectClient);
|
|
iSize = rectClient.Width() / 90;
|
|
|
|
iLeft = iX - iSize / 2;
|
|
iTop = iY - iSize / 2 + 1;
|
|
iRight = iX + iSize / 2;
|
|
iBottom = iY + iSize / 2 + 1;
|
|
|
|
brushPt.CreateSolidBrush(crColor);
|
|
pBrushOldPt = pDC->SelectObject(&brushPt);
|
|
|
|
rectPoint.SetRect(iLeft, iTop, iRight, iBottom);
|
|
pDC->Ellipse(rectPoint);
|
|
// pDC->DrawText(_T("*"), rectPoint, DT_SINGLELINE | DT_VCENTER | DT_BOTTOM);
|
|
// pDC->DrawText(_T("+"), rectPoint, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
|
|
|
|
brushPt.DeleteObject();
|
|
pDC->SelectObject(pBrushOldPt);
|
|
}
|
|
|
|
return rectPoint;
|
|
}
|