299 lines
7.9 KiB
C++
299 lines
7.9 KiB
C++
// opexeccersptesttdview.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "geomative.h"
|
|
#include "opexeccersptesttdview.h"
|
|
|
|
#include "TdChannel.h"
|
|
#include "RspCETdRecord.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COpExecCERSPTestTdView
|
|
|
|
IMPLEMENT_DYNCREATE(COpExecCERSPTestTdView, CView)
|
|
|
|
COpExecCERSPTestTdView::COpExecCERSPTestTdView()
|
|
{
|
|
m_pTdChannel = NULL;
|
|
|
|
m_fMaxCX = 0.0;
|
|
m_fMaxCY = 0.0;
|
|
m_iCXOffset = 60;
|
|
m_iCYOffset = 40;
|
|
}
|
|
|
|
COpExecCERSPTestTdView::~COpExecCERSPTestTdView()
|
|
{
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(COpExecCERSPTestTdView, CView)
|
|
//{{AFX_MSG_MAP(COpExecCERSPTestTdView)
|
|
ON_WM_MOUSEACTIVATE()
|
|
ON_WM_CANCELMODE()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COpExecCERSPTestTdView drawing
|
|
|
|
void COpExecCERSPTestTdView::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);
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COpExecCERSPTestTdView diagnostics
|
|
|
|
#ifdef _DEBUG
|
|
void COpExecCERSPTestTdView::AssertValid() const
|
|
{
|
|
CView::AssertValid();
|
|
}
|
|
|
|
void COpExecCERSPTestTdView::Dump(CDumpContext& dc) const
|
|
{
|
|
CView::Dump(dc);
|
|
}
|
|
#endif //_DEBUG
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COpExecCERSPTestTdView message handlers
|
|
|
|
void COpExecCERSPTestTdView::OnInitialUpdate()
|
|
{
|
|
CView::OnInitialUpdate();
|
|
|
|
// TODO: Add your specialized code here and/or call the base class
|
|
if (NULL != m_pTdChannel)
|
|
{
|
|
this->m_fMaxCX = (float)(m_pTdChannel->m_fMaxR0 * 1.1);
|
|
this->m_fMaxCY = (float)ceil(m_pTdChannel->m_fMaxDepth);
|
|
}
|
|
}
|
|
|
|
int COpExecCERSPTestTdView::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT msg)
|
|
{
|
|
return APP_SUCCESS;
|
|
}
|
|
|
|
CRect COpExecCERSPTestTdView::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;
|
|
}
|
|
|
|
void COpExecCERSPTestTdView::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 COpExecCERSPTestTdView::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);
|
|
}
|
|
|
|
int COpExecCERSPTestTdView::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 COpExecCERSPTestTdView::OnCancelMode()
|
|
{
|
|
CView::OnCancelMode();
|
|
|
|
// TODO: Add your message handler code here
|
|
}
|
|
|
|
BOOL COpExecCERSPTestTdView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
|
|
{
|
|
// TODO: Add your specialized code here and/or call the base class
|
|
|
|
m_scroll.Create( SBS_HORZ | SBS_TOPALIGN, CRect( 0, 0, 300, 200), pParentWnd, 0 );
|
|
m_scroll.ShowScrollBar();
|
|
|
|
return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
|
|
}
|
|
|
|
BOOL COpExecCERSPTestTdView::PreCreateWindow(CREATESTRUCT& cs)
|
|
{
|
|
// TODO: Add your specialized code here and/or call the base class
|
|
|
|
cs.style=cs.style|WS_HSCROLL|WS_VSCROLL;
|
|
|
|
return CView::PreCreateWindow(cs);
|
|
}
|