Files
geomative/GeomativeStudio/cpp/Views/opexec2drsptesttdview.cpp
T
coco df489d5640 a
2026-07-03 16:05:30 +08:00

275 lines
7.3 KiB
C++

// opexec2drsptesttdview.cpp : implementation file
//
#include "stdafx.h"
#include "geomative.h"
#include "opexec2drsptesttdview.h"
#include "TdChannel.h"
#include "RSP2DTdRecord.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COpExec2DRSPTestTdView
IMPLEMENT_DYNCREATE(COpExec2DRSPTestTdView, CView)
COpExec2DRSPTestTdView::COpExec2DRSPTestTdView()
{
m_pTdChannel = NULL;
m_pCurTdRecord = NULL;
m_pMemDC = NULL;
m_lRect.SetRectEmpty();
m_iSmWidth = (int)VAL_ZERO;
m_iSmHeight = (int)VAL_ZERO;
}
COpExec2DRSPTestTdView::~COpExec2DRSPTestTdView()
{
}
BEGIN_MESSAGE_MAP(COpExec2DRSPTestTdView, CView)
//{{AFX_MSG_MAP(COpExec2DRSPTestTdView)
ON_WM_MOVE()
ON_WM_SIZE()
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COpExec2DRSPTestTdView drawing
void COpExec2DRSPTestTdView::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
CRsp2DTdRecord* pRsp2DTdRecord = NULL;
CBrush brush;
CPen lPen(PS_SOLID, 1, RGB(180, 180, 180));
CPen* pOldLPen = NULL;
CRect vRect;
CRect cRect;
int iIndex = (int)VAL_ZERO;
CString szLabel = _T("");
int iScaleX = (int)VAL_ZERO;
int iScaleY = (int)VAL_ZERO;
// int q = m_pTdChannel->m_tdRecArray.GetSize();
if ((this->m_pTdChannel != NULL) && (m_pTdChannel->m_tdRecArray.GetSize() > 0))
{
this->GetClientRect(vRect);
pDC->FillSolidRect(m_lRect, RGB(255, 255, 255));
DrawColorTable(pDC);
while (iScaleX < this->m_pTdChannel->m_iEAmount)
{
if ((0 == (iScaleX+1)%12) || (0 == iScaleX))
{
pDC->MoveTo(m_lRect.left+(m_iSmWidth-1)*iScaleX, m_lRect.top-10);
pDC->LineTo(m_lRect.left+(m_iSmWidth-1)*iScaleX, m_lRect.top);
cRect.SetRectEmpty();
cRect.left = m_lRect.left+(m_iSmWidth-1)*iScaleX-12;
cRect.top = m_lRect.top-10-12;
cRect.right = m_lRect.left+(m_iSmWidth-1)*iScaleX+12;
cRect.bottom = m_lRect.top-10-2;
szLabel.Empty();
szLabel.Format(_T("%d"), iScaleX+1);
pDC->DrawText(szLabel, &cRect, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
pDC->MoveTo(m_lRect.left+(m_iSmWidth-1)*iScaleX, m_lRect.bottom);
pDC->LineTo(m_lRect.left+(m_iSmWidth-1)*iScaleX, m_lRect.bottom+10);
cRect.SetRectEmpty();
cRect.left = m_lRect.left+(m_iSmWidth-1)*iScaleX-12;
cRect.top = m_lRect.bottom+10+2;
cRect.right = m_lRect.left+(m_iSmWidth-1)*iScaleX+12;
cRect.bottom = m_lRect.bottom+10+12;
szLabel.Empty();
szLabel.Format(_T("%d"), iScaleX+1);
pDC->DrawText(szLabel, &cRect, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
}
else
{
pDC->MoveTo(m_lRect.left+(m_iSmWidth-1)*iScaleX, m_lRect.top-5);
pDC->LineTo(m_lRect.left+(m_iSmWidth-1)*iScaleX, m_lRect.top);
pDC->MoveTo(m_lRect.left+(m_iSmWidth-1)*iScaleX, m_lRect.bottom+5);
pDC->LineTo(m_lRect.left+(m_iSmWidth-1)*iScaleX, m_lRect.bottom-1);
}
iScaleX++;
}
while (iScaleY < this->m_pTdChannel->m_iMaxLevel)
{
if ((0 == (iScaleY+1)%5) || (0 == iScaleY))
{
pDC->MoveTo(m_lRect.left-10, m_lRect.top+(m_iSmHeight-1)/2*(2*iScaleY+1));
pDC->LineTo(m_lRect.left, m_lRect.top+(m_iSmHeight-1)/2*(2*iScaleY+1));
cRect.SetRectEmpty();
cRect.left = m_lRect.left-10-22;
cRect.top = m_lRect.top+(m_iSmHeight-1)/2*(2*iScaleY+1)-5;
cRect.right = m_lRect.left-10-2;
cRect.bottom = m_lRect.top+(m_iSmHeight-1)/2*(2*iScaleY+1)+5;
szLabel.Empty();
szLabel.Format(_T("%d"), iScaleY+1);
pDC->DrawText(szLabel, &cRect, DT_SINGLELINE | DT_VCENTER | DT_RIGHT);
pDC->MoveTo(m_lRect.right, m_lRect.top+(m_iSmHeight-1)/2*(2*iScaleY+1));
pDC->LineTo(m_lRect.right+10, m_lRect.top+(m_iSmHeight-1)/2*(2*iScaleY+1));
cRect.SetRectEmpty();
cRect.left = m_lRect.right+10+2;
cRect.top = m_lRect.top+(m_iSmHeight-1)/2*(2*iScaleY+1)-5;
cRect.right = m_lRect.right+10+22;
cRect.bottom = m_lRect.top+(m_iSmHeight-1)/2*(2*iScaleY+1)+5;
szLabel.Empty();
szLabel.Format(_T("%d"), iScaleY+1);
pDC->DrawText(szLabel, &cRect, DT_SINGLELINE | DT_VCENTER | DT_LEFT);
}
else
{
pDC->MoveTo(m_lRect.left-5, m_lRect.top+(m_iSmHeight-1)/2*(2*iScaleY+1));
pDC->LineTo(m_lRect.left, m_lRect.top+(m_iSmHeight-1)/2*(2*iScaleY+1));
pDC->MoveTo(m_lRect.right, m_lRect.top+(m_iSmHeight-1)/2*(2*iScaleY+1));
pDC->LineTo(m_lRect.right+5, m_lRect.top+(m_iSmHeight-1)/2*(2*iScaleY+1));
}
iScaleY++;
}
brush.DeleteObject();
while (iIndex < this->m_pTdChannel->m_tdRecArray.GetSize())
{
pRsp2DTdRecord = (CRsp2DTdRecord*)this->m_pTdChannel->m_tdRecArray.GetAt(iIndex);
this->m_pTdChannel->SetColorToTdRec(pRsp2DTdRecord);
pDC->SelectStockObject(NULL_BRUSH);
pOldLPen = pDC->SelectObject(&lPen);
pDC->Rectangle(pRsp2DTdRecord->m_recPtArea);
pDC->SelectObject(pOldLPen);
if (pRsp2DTdRecord->m_colorREF != RGB(0xFF, 0xFF, 0xFF))
{
brush.CreateSolidBrush(pRsp2DTdRecord->m_colorREF);
}
else
{
pDC->SelectStockObject(NULL_BRUSH);
}
pDC->FillRect(pRsp2DTdRecord->m_recPtArea, &brush);
brush.DeleteObject();
iIndex++;
}
pDC->SelectStockObject(NULL_BRUSH);
pDC->Rectangle(m_lRect);
}
}
/////////////////////////////////////////////////////////////////////////////
// COpExec2DRSPTestTdView diagnostics
#ifdef _DEBUG
void COpExec2DRSPTestTdView::AssertValid() const
{
CView::AssertValid();
}
void COpExec2DRSPTestTdView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// COpExec2DRSPTestTdView message handlers
void COpExec2DRSPTestTdView::OnMove(int x, int y)
{
CView::OnMove(x, y);
// TODO: Add your message handler code here
this->Invalidate();
// AfxMessageBox("on move");
}
void COpExec2DRSPTestTdView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
CClientDC dc(this);
CRect vRect;
CRect lRect;
int iSmWidth = 0;
int iSmHeight = 0;
this->GetClientRect(vRect);
dc.FillSolidRect(vRect, RGB(0xFF,0xFF,0xFF));
if (NULL != m_pTdChannel)
{
m_pTdChannel->m_pMedium->CalculateTdPtLoc(vRect, m_pTdChannel->m_iEAmount, m_pTdChannel->m_iMaxLevel, lRect, iSmWidth, iSmHeight, &m_pTdChannel->m_tdRecArray);
this->m_lRect = lRect;
this->m_iSmWidth = iSmWidth;
this->m_iSmHeight = iSmHeight;
}
this->Invalidate();
// AfxMessageBox("on size");
}
BOOL COpExec2DRSPTestTdView::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
// return TRUE;
return CView::OnEraseBkgnd(pDC);
}
void COpExec2DRSPTestTdView::DrawColorTable(CDC* pDC)
{
// AfxMessageBox("drawColorTable");
int iColorIndex = (int)VAL_ZERO;
COLORREF aColor[15]={RGB(0,0,0xFF),RGB(0,0x33,0xFF),RGB(0,0x66,0xFF),RGB(0,0x88,0xFF),RGB(0,0xCF,0xFE),RGB(0,0xFE,0xFF),RGB(0,0xFE,0x99),RGB(0,0xFE,0x33),RGB(0x99,0xFE,0),RGB(0xFF,0xFE,0),RGB(0xFE,0xCC,0),RGB(0xFE,0x98,0),RGB(0xFE,0x66,0),RGB(0xFE,0x33,0),RGB(0xFF,0,0)};
CBrush brush;
CRect tRect;
iColorIndex = (int)VAL_ZERO;
while (iColorIndex < 15)
{
tRect.SetRectEmpty();
tRect.left = 20;
tRect.top = 40+iColorIndex*20;
tRect.right = 20+20;
tRect.bottom = 60+iColorIndex*20;
pDC->Rectangle(tRect);
brush.CreateSolidBrush(aColor[iColorIndex]);
pDC->FillRect(tRect, &brush);
brush.DeleteObject();
iColorIndex++;
}
}