// Browse2DScriptView.cpp : implementation file // #include "stdafx.h" #include "geomative.h" #include "Browse2DScriptView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CBrowse2DScriptView IMPLEMENT_DYNCREATE(CBrowse2DScriptView, CScrollView) CBrowse2DScriptView::CBrowse2DScriptView() { m_iMul = (int)VAL_ZERO; m_pMemDC = NULL; m_pNewChannel = NULL; m_pCurSptRecord = NULL; m_bIsDraw = FALSE; m_pSource = NULL; // TODO: calculate the total size of this view } CBrowse2DScriptView::~CBrowse2DScriptView() { } BEGIN_MESSAGE_MAP(CBrowse2DScriptView, CScrollView) //{{AFX_MSG_MAP(CBrowse2DScriptView) ON_WM_MOUSEWHEEL() ON_WM_ERASEBKGND() ON_WM_HSCROLL() ON_WM_VSCROLL() ON_WM_MOUSEACTIVATE() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CBrowse2DScriptView drawing void CBrowse2DScriptView::OnDraw(CDC* pDC) { CDocument* pDoc = GetDocument(); // TODO: add draw code here int iRecIndex = (int)VAL_ZERO; int iRecCount = (int)VAL_ZERO; CDC* pMemDC = new CDC; CBitmap* pMemBmp = new CBitmap; CBitmap* pOldMemBmp = NULL; CRect rectMemBmp; CRect rectView; int iMaxViewWidth = (int)VAL_ZERO; int iMaxViewHeight = (int)VAL_ZERO; this->GetClientRect(&rectView); if ((NULL != m_pNewChannel) && (TRUE == m_bIsDraw)) { iRecCount = m_pNewChannel->m_sptRecArray.GetSize(); if (iRecCount > 0) { rectMemBmp.left = 0; rectMemBmp.top = 0; rectMemBmp.right = 200+(m_iEAmount-1)*(6+2)*m_iMul; rectMemBmp.bottom = 200+(m_pNewChannel->m_iMaxLevel-1)*(6+2)*m_iMul; if (rectMemBmp.Width() >= rectView.Width()) { iMaxViewWidth = rectMemBmp.Width(); } else { iMaxViewWidth = rectView.Width(); } if (rectMemBmp.Height() >= rectView.Height()) { iMaxViewHeight = rectMemBmp.Height(); } else { iMaxViewHeight = rectView.Height(); } pMemDC->CreateCompatibleDC(pDC); pMemBmp->CreateCompatibleBitmap(pDC, iMaxViewWidth, iMaxViewHeight); pOldMemBmp = pMemDC->SelectObject(pMemBmp); pMemDC->FillSolidRect((int)VAL_ZERO, (int)VAL_ZERO, iMaxViewWidth, iMaxViewHeight, RGB(255,255,255)); this->DrawEX(pMemDC); this->DrawLY(pMemDC); this->DrawRecPoint(iRecCount, pMemDC); // while (iRecIndex < iRecCount) // { // pSptRecord = (CSptRecord*)m_pNewChannel->m_sptRecArray.GetAt(iRecIndex); // this->m_pNewChannel->m_pMedium->CalculatePtLoc(m_iMul, pSptRecord); // pMemDC->Ellipse(pSptRecord->m_recPtArea); // iRecIndex++; // } pDC->BitBlt((int)VAL_ZERO, (int)VAL_ZERO, iMaxViewWidth, iMaxViewHeight, pMemDC, (int)VAL_ZERO, (int)VAL_ZERO, SRCCOPY); pMemDC->SelectObject(pOldMemBmp); pMemBmp->DeleteObject(); pMemDC->DeleteDC(); delete pMemBmp; delete pMemDC; SetScrollSizes(MM_TEXT, CSize(m_iWinWidth, m_iWinHeight)); // CDC* DemoDC = NULL; // if (NULL != ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptInfoView) // { // DemoDC = ((COpCreateSptFrame*)GetParentFrame())->m_pOpCreateSptInfoView->GetDC(); // } // DemoDC->TextOut(20, 20, "OK"); } } else { pDC->FillSolidRect((int)VAL_ZERO, (int)VAL_ZERO, rectView.Width(), rectView.Height(), RGB(255,255,255)); } } void CBrowse2DScriptView::DrawEX(CDC* const pMemDC) { int iCurENum = (int)VAL_ZERO; CString szLabel = _T(""); CFont ftEX; CFont* pFtOldEX; if (m_iEAmount < 1000) { ftEX.CreatePointFont(68, _T("Tahoma")); } else { ftEX.CreatePointFont(65, _T("Tahoma")); } pFtOldEX = pMemDC->SelectObject(&ftEX); pMemDC->SetBkMode(OPAQUE); for (iCurENum=1; iCurENum <= m_iEAmount; iCurENum++) { szLabel.Empty(); szLabel.Format("%d", iCurENum); pMemDC->DrawText(szLabel, CRect(32+(iCurENum-1)*(6+2)*m_iMul, 10, 62+(iCurENum-1)*(6+2)*m_iMul, 30), DT_SINGLELINE | DT_VCENTER | DT_CENTER); pMemDC->MoveTo(46+(iCurENum-1)*(6+2)*m_iMul, 30); pMemDC->LineTo(46+(iCurENum-1)*(6+2)*m_iMul, 40); } pMemDC->MoveTo(46, 40); pMemDC->LineTo(46+(iCurENum-2)*(6+2)*m_iMul, 40); ftEX.DeleteObject(); pMemDC->SelectObject(pFtOldEX); this->m_iWinWidth = 46+(iCurENum-1)*(6+2)*m_iMul+50; } void CBrowse2DScriptView::DrawLY(CDC* const pMemDC) { int iCurLNum = (int)VAL_ZERO; CString szLabel = _T(""); CFont ftLY; CFont* pFtOldLY = NULL; CPen lPen(PS_DOT, 1, RGB(180, 180, 180)); CPen* pOldLPen = NULL; if (m_iEAmount < 1000) { ftLY.CreatePointFont(70, _T("Tahoma")); } else { ftLY.CreatePointFont(65, _T("Tahoma")); } pFtOldLY = pMemDC->SelectObject(&ftLY); pMemDC->SetBkMode(OPAQUE); for (iCurLNum=1; iCurLNum <= (m_pNewChannel->m_iMaxLevel); iCurLNum++) { szLabel.Empty(); szLabel.Format("%d", iCurLNum); pMemDC->DrawText(szLabel, CRect(10, 50+(iCurLNum-1)*(6+2)*m_iMul, 30, (50+6*m_iMul)+(iCurLNum-1)*(6+2)*m_iMul), DT_SINGLELINE | DT_VCENTER | DT_CENTER); pMemDC->MoveTo(30, (50+3*m_iMul)+(iCurLNum-1)*(6+2)*m_iMul); pMemDC->LineTo(40, (50+3*m_iMul)+(iCurLNum-1)*(6+2)*m_iMul); pOldLPen = pMemDC->SelectObject(&lPen); pMemDC->LineTo(51+(m_iEAmount-1)*(6+2)*m_iMul, (50+3*m_iMul)+(iCurLNum-1)*(6+2)*m_iMul); pMemDC->SelectObject(pOldLPen); pMemDC->MoveTo(52+(m_iEAmount-1)*(6+2)*m_iMul, (50+3*m_iMul)+(iCurLNum-1)*(6+2)*m_iMul); pMemDC->LineTo(62+(m_iEAmount-1)*(6+2)*m_iMul, (50+3*m_iMul)+(iCurLNum-1)*(6+2)*m_iMul); pMemDC->DrawText(szLabel, CRect(5+62+(m_iEAmount-1)*(6+2)*m_iMul, 50+(iCurLNum-1)*(6+2)*m_iMul, 25+62+(m_iEAmount-1)*(6+2)*m_iMul, (50+6*m_iMul)+(iCurLNum-1)*(6+2)*m_iMul), DT_SINGLELINE | DT_VCENTER | DT_CENTER); } pMemDC->MoveTo(40, 50+3*m_iMul); pMemDC->LineTo(40, 50+3*m_iMul+(iCurLNum-2)*(6+2)*m_iMul); pMemDC->MoveTo(52+(m_iEAmount-1)*(6+2)*m_iMul, 50+3*m_iMul); pMemDC->LineTo(52+(m_iEAmount-1)*(6+2)*m_iMul, (50+3*m_iMul)+(iCurLNum-2)*(6+2)*m_iMul); ftLY.DeleteObject(); pMemDC->SelectObject(pFtOldLY); this->m_iWinHeight = (50+3*m_iMul)+(iCurLNum-1)*(6+2)*m_iMul+50; } void CBrowse2DScriptView::DrawRecPoint(int iRecCount, CDC* const pMemDC) { CString szLabel = _T(""); int iRecIndex = (int)VAL_ZERO; CSptRecord* pSptRecord = NULL; CBrush BshPt; CBrush* pOldBshPt = NULL; CFont ftPt; CFont* pOldFtPt = NULL; ftPt.CreatePointFont(20+10*m_iMul, _T("Tahoma")); pOldFtPt = pMemDC->SelectObject(&ftPt); pMemDC->SetBkMode(TRANSPARENT); while (iRecIndex < iRecCount) { pSptRecord = (CSptRecord*)m_pNewChannel->m_sptRecArray.GetAt(iRecIndex); this->m_pNewChannel->m_pMedium->CalculateSptPtLoc(m_iMul, pSptRecord); BshPt.CreateSolidBrush(pSptRecord->m_colorREF); // BshPt.CreateSolidBrush(RGB(0,255,0)); pOldBshPt = pMemDC->SelectObject(&BshPt); szLabel.Empty(); szLabel.Format(_T("%d"), pSptRecord->m_iTsn); pMemDC->Ellipse(pSptRecord->m_recPtArea); pMemDC->DrawText(szLabel, pSptRecord->m_recPtArea, DT_SINGLELINE | DT_VCENTER | DT_CENTER); BshPt.DeleteObject(); iRecIndex++; } ftPt.DeleteObject(); pMemDC->SelectObject(pOldBshPt); pMemDC->SelectObject(pOldFtPt); } ///////////////////////////////////////////////////////////////////////////// // CBrowse2DScriptView diagnostics #ifdef _DEBUG void CBrowse2DScriptView::AssertValid() const { CScrollView::AssertValid(); } void CBrowse2DScriptView::Dump(CDumpContext& dc) const { CScrollView::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CBrowse2DScriptView message handlers BOOL CBrowse2DScriptView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) { // TODO: Add your message handler code here and/or call default if (zDelta > 0) { if (m_iMul < 5) { m_iMul++; } } else { if (m_iMul > 2) { m_iMul--; } } this->Invalidate(FALSE); return CScrollView::OnMouseWheel(nFlags, zDelta, pt); } BOOL CBrowse2DScriptView::OnEraseBkgnd(CDC* pDC) { // TODO: Add your message handler code here and/or call default return TRUE; // return CScrollView::OnEraseBkgnd(pDC); } void CBrowse2DScriptView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { // TODO: Add your message handler code here and/or call default this->Invalidate(FALSE); CScrollView::OnHScroll(nSBCode, nPos, pScrollBar); } void CBrowse2DScriptView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { // TODO: Add your message handler code here and/or call default this->Invalidate(FALSE); CScrollView::OnVScroll(nSBCode, nPos, pScrollBar); } void CBrowse2DScriptView::OnInitialUpdate() { CScrollView::OnInitialUpdate(); // TODO: Add your specialized code here and/or call the base class CSize sizeTotal; sizeTotal.cx = sizeTotal.cy = 0; SetScrollSizes(MM_TEXT, sizeTotal); m_iMul = 5; } int CBrowse2DScriptView::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message) { // TODO: Add your message handler code here and/or call default //return CScrollView::OnMouseActivate(pDesktopWnd, nHitTest, message); return CWnd::OnMouseActivate(pDesktopWnd, nHitTest, message); } void CBrowse2DScriptView::SetSelectPoint(CPtrArray *pSource) { m_pSource = pSource; } //DEL BOOL CBrowse2DScriptView::CheckSelect() //DEL { //DEL CSptRecord *cSrcRecord; //DEL CSptRecord *cTarRecord; //DEL //DEL for (int n = 0; n < m_pSource->GetSize(); n++) //DEL { //DEL cTarRecord = (CSptRecord *)m_pNewChannel->m_sptRecArray.GetAt(n); //DEL cSrcRecord = (CSptRecord *)m_pSource->GetAt(n); //DEL //DEL if (cSrcRecord->m_iTsn != cTarRecord->m_iTsn) //DEL return FALSE; //DEL //DEL if (cSrcRecord->m_iC1 != cTarRecord->m_iC1) //DEL return FALSE; //DEL //DEL if (cSrcRecord->m_iC2 != cTarRecord->m_iC2) //DEL return FALSE; //DEL //DEL if (cSrcRecord->m_iP1 != cTarRecord->m_iP2) //DEL return FALSE; //DEL //DEL if (cSrcRecord->m_iP2 != cTarRecord->m_iP2) //DEL return FALSE; //DEL //DEL if (cSrcRecord->m_fK != cTarRecord->m_fK) //DEL return FALSE; //DEL //DEL if (cSrcRecord->m_iN != cTarRecord->m_iN) //DEL return FALSE; //DEL } //DEL //DEL //DEL return TRUE; //DEL }