256 lines
6.3 KiB
C++
256 lines
6.3 KiB
C++
// dispgrapcersptdview.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "geomative.h"
|
|
#include "dispgrapcersptdview.h"
|
|
|
|
#include "TdChannel.h"
|
|
#include "RspCETdRecord.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CDispGrapCERSPTdView
|
|
|
|
IMPLEMENT_DYNCREATE(CDispGrapCERSPTdView, CView)
|
|
|
|
CDispGrapCERSPTdView::CDispGrapCERSPTdView()
|
|
{
|
|
m_fMaxCX = 0.0;
|
|
m_fMaxCY = 0.0;
|
|
m_iCXOffset = 60;
|
|
m_iCYOffset = 40;
|
|
}
|
|
|
|
CDispGrapCERSPTdView::~CDispGrapCERSPTdView()
|
|
{
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CDispGrapCERSPTdView, CView)
|
|
//{{AFX_MSG_MAP(CDispGrapCERSPTdView)
|
|
// NOTE - the ClassWizard will add and remove mapping macros here.
|
|
ON_WM_MOUSEACTIVATE()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CDispGrapCERSPTdView drawing
|
|
|
|
void CDispGrapCERSPTdView::OnDraw(CDC* pDC)
|
|
{
|
|
CDocument* pDoc = GetDocument();
|
|
// TODO: add draw code here
|
|
int iIndex = 0;
|
|
|
|
CBrush brushPt;
|
|
CBrush* pBrushOldPt = NULL;
|
|
|
|
DrawEX(pDC);
|
|
DrawLY(pDC);
|
|
|
|
iIndex = 0;
|
|
while (iIndex < m_pTdChannel->m_tdRecArray.GetSize())
|
|
{
|
|
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++;
|
|
}
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CDispGrapCERSPTdView diagnostics
|
|
|
|
#ifdef _DEBUG
|
|
void CDispGrapCERSPTdView::AssertValid() const
|
|
{
|
|
CView::AssertValid();
|
|
}
|
|
|
|
void CDispGrapCERSPTdView::Dump(CDumpContext& dc) const
|
|
{
|
|
CView::Dump(dc);
|
|
}
|
|
#endif //_DEBUG
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CDispGrapCERSPTdView message handlers
|
|
|
|
int CDispGrapCERSPTdView::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT msg)
|
|
{
|
|
return APP_SUCCESS;
|
|
}
|
|
|
|
void CDispGrapCERSPTdView::OnInitialUpdate()
|
|
{
|
|
CView::OnInitialUpdate();
|
|
|
|
// TODO: Add your specialized code here and/or call the base class
|
|
this->m_fMaxCX = (float)(m_pTdChannel->m_fMaxR0 * 1.1);
|
|
this->m_fMaxCY = (float)ceil(m_pTdChannel->m_fMaxDepth);
|
|
}
|
|
|
|
CRect CDispGrapCERSPTdView::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 CDispGrapCERSPTdView::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 * 70, m_iCYOffset - 10);
|
|
pDC->LineTo(m_iCXOffset + iIndex * 70, m_iCYOffset - 18);
|
|
|
|
szLabel.Empty();
|
|
szLabel.Format(_T("%.2f"), iIndex * (this->m_fMaxCX / 10));
|
|
|
|
pDC->DrawText(szLabel, CRect(m_iCXOffset + iIndex * 70 - 15, m_iCYOffset - 28, m_iCXOffset + iIndex * 70 + 15, m_iCYOffset - 18), DT_SINGLELINE | DT_VCENTER | DT_CENTER);
|
|
|
|
if (10 != iIndex)
|
|
{
|
|
pDC->MoveTo(m_iCXOffset + iIndex * 70 + 35, m_iCYOffset - 10);
|
|
pDC->LineTo(m_iCXOffset + iIndex * 70 + 35, m_iCYOffset - 14);
|
|
}
|
|
iIndex++;
|
|
}
|
|
|
|
fontEX.DeleteObject();
|
|
pDC->SelectObject(pFontOldEX);
|
|
}
|
|
|
|
void CDispGrapCERSPTdView::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 * 40);
|
|
pDC->LineTo(m_iCXOffset - 18, m_iCYOffset + iIndex * 40);
|
|
|
|
pPenOld = pDC->SelectObject(&penDot);
|
|
pDC->MoveTo(m_iCXOffset - 10, m_iCYOffset + iIndex * 40);
|
|
pDC->LineTo(m_iCXOffset + 710, m_iCYOffset + iIndex * 40);
|
|
pDC->SelectObject(pPenOld);
|
|
|
|
szLabel.Empty();
|
|
szLabel.Format(_T("%.1f"), iIndex * (this->m_fMaxCY / 10));
|
|
|
|
pDC->DrawText(szLabel, CRect(m_iCXOffset - 38, m_iCYOffset + iIndex * 40 - 5, m_iCXOffset - 18, m_iCYOffset + iIndex * 40 + 5), DT_SINGLELINE | DT_VCENTER | DT_CENTER);
|
|
|
|
if (10 != iIndex)
|
|
{
|
|
pDC->MoveTo(m_iCXOffset - 10, m_iCYOffset + iIndex * 40 + 20);
|
|
pDC->LineTo(m_iCXOffset - 14, m_iCYOffset + iIndex * 40 + 20);
|
|
}
|
|
|
|
iIndex++;
|
|
}
|
|
|
|
pDC->MoveTo(m_iCXOffset + 710, m_iCYOffset);
|
|
pDC->LineTo(m_iCXOffset + 710, m_iCYOffset + 400);
|
|
|
|
iIndex = 0;
|
|
while (iIndex <= 10)
|
|
{
|
|
pDC->MoveTo(m_iCXOffset + 710, m_iCYOffset + iIndex * 40);
|
|
pDC->LineTo(m_iCXOffset + 718, m_iCYOffset + iIndex * 40);
|
|
|
|
szLabel.Empty();
|
|
szLabel.Format(_T("%.1f"), iIndex * (this->m_fMaxCY / 10));
|
|
|
|
pDC->DrawText(szLabel, CRect(m_iCXOffset + 718, m_iCYOffset + iIndex * 40 - 5, m_iCXOffset + 738, m_iCYOffset + iIndex * 40 + 5), DT_SINGLELINE | DT_VCENTER | DT_CENTER);
|
|
|
|
if (10 != iIndex)
|
|
{
|
|
pDC->MoveTo(m_iCXOffset + 710, m_iCYOffset + iIndex * 40 + 20);
|
|
pDC->LineTo(m_iCXOffset + 714, m_iCYOffset + iIndex * 40 + 20);
|
|
}
|
|
|
|
iIndex++;
|
|
}
|
|
|
|
fontEX.DeleteObject();
|
|
pDC->SelectObject(pFontOldEX);
|
|
}
|
|
|
|
int CDispGrapCERSPTdView::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);
|
|
}
|