ZProject.cpp
上传用户:wangdan
上传日期:2022-06-30
资源大小:739k
文件大小:3k
- // ZProject.cpp : implementation file
- //
- #include "stdafx.h"
- #include "Test1.h"
- #include "ZProject.h"
- #include "MainFrm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CZProject
- extern GLfloat Databuf[ArrayOne][ArrayTwo];
- extern bool gbIsGetData;
- extern bool gbDataIsEmpty;
- IMPLEMENT_DYNCREATE(CZProject, CView)
- CZProject::CZProject()
- {
- }
- CZProject::~CZProject()
- {
- }
- BEGIN_MESSAGE_MAP(CZProject, CView)
- //{{AFX_MSG_MAP(CZProject)
- ON_WM_ERASEBKGND()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CZProject drawing
- void CZProject::OnDraw(CDC* pDC)
- {
- CDocument* pDoc = GetDocument();
- CRect rc;
- GetClientRect(&rc);
- pDC->SetTextAlign(TA_CENTER);
- pDC->SetTextColor(YELLOW);
- pDC->SetBkMode(1);
- CFont *OldFont = pDC->SelectObject(&this->m_pFr->m_13Font);
-
- CPen *pen = new CPen(PS_SOLID,1,GREEN);
- CPen *pOldPen = pDC->SelectObject(pen);
- pDC->TextOut(rc.right/2,2,"Z轴投影-密度");
- //x轴
- pDC->MoveTo(10,rc.bottom-20);
- pDC->LineTo(rc.right-30,rc.bottom-20);
- pDC->MoveTo(rc.right-30,rc.bottom-20);
- pDC->LineTo(rc.right-30-5,rc.bottom-20-5);
- pDC->MoveTo(rc.right-30,rc.bottom-20);
- pDC->LineTo(rc.right-30-5,rc.bottom-20+5);
- //y轴
- pDC->MoveTo(10,rc.bottom-20);
- pDC->LineTo(10,25);
- pDC->MoveTo(10,25);
- pDC->LineTo(5,30);
- pDC->MoveTo(10,25);
- pDC->LineTo(15,30);
- this->DrawZCoordinate(pDC);
- this->ZProjection(pDC);
- pDC->SelectObject(pOldPen);
- pDC->SelectObject(OldFont);
- delete pen;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CZProject diagnostics
- #ifdef _DEBUG
- void CZProject::AssertValid() const
- {
- CView::AssertValid();
- }
- void CZProject::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CZProject message handlers
- BOOL CZProject::OnEraseBkgnd(CDC* pDC)
- {
- CBrush Brush (BLACK);
- CBrush* pOldBrush = pDC->SelectObject(&Brush);
- CRect ViewClip;
- pDC->GetClipBox(&ViewClip);
- pDC->PatBlt(ViewClip.left,ViewClip.top,ViewClip.Width(),ViewClip.Height(),PATCOPY);
- pDC->SelectObject (pOldBrush );
- return TRUE;
- }
- void CZProject::OnInitialUpdate()
- {
- CView::OnInitialUpdate();
-
- this->m_pFr = (CMainFrame*)AfxGetApp()->m_pMainWnd;
- }
- void CZProject::DrawZCoordinate(CDC *pDC)
- {
- CRect rc;
- this->GetClientRect(&rc);
- pDC->SetTextAlign(TA_LEFT);
- pDC->TextOut(2,rc.bottom-15,"0");
- pDC->TextOut(rc.right-30,rc.bottom-25,"声波");
- pDC->TextOut(0,10,"中子");
- }
- void CZProject::ZProjection(CDC *pDC)
- {
- if (::gbIsGetData)
- return;
- if (::gbDataIsEmpty)
- return;
- CRect rc;
- GetClientRect(&rc);
- for (int i=0; i<ArrayOne; i++)
- {
- if ((GLfloat)Databuf[i][0] >= this->m_pFr->m_pView->m_nMinDepth
- && (GLfloat)Databuf[i][0] <= this->m_pFr->m_pView->m_nMaxDepth )
- {
- pDC->SetPixel(Databuf[i][this->m_pFr->m_pView->m_First]/3-10
- ,(rc.bottom-20) -( Databuf[i][this->m_pFr->m_pView->m_Second]*3+20 )
- ,BLUE);
- }
- }
- }