YProject.cpp
上传用户:wangdan
上传日期:2022-06-30
资源大小:739k
文件大小:3k
- // YProject.cpp : implementation file
- //
- #include "stdafx.h"
- #include "Test1.h"
- #include "YProject.h"
- #include "MainFrm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CYProject
- extern GLfloat Databuf[ArrayOne][ArrayTwo];
- extern bool gbIsGetData;
- extern bool gbDataIsEmpty;
- IMPLEMENT_DYNCREATE(CYProject, CView)
- CYProject::CYProject()
- {
- }
- CYProject::~CYProject()
- {
- }
- BEGIN_MESSAGE_MAP(CYProject, CView)
- //{{AFX_MSG_MAP(CYProject)
- ON_WM_ERASEBKGND()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CYProject drawing
- void CYProject::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,"Y轴投影-中子");
- this->DrawYCoordinate(pDC);
- this->YProjection(pDC);
- pDC->SelectObject(pOldPen);
- pDC->SelectObject(OldFont);
- delete pen;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CYProject diagnostics
- #ifdef _DEBUG
- void CYProject::AssertValid() const
- {
- CView::AssertValid();
- }
- void CYProject::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CYProject message handlers
- BOOL CYProject::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 CYProject::OnInitialUpdate()
- {
- CView::OnInitialUpdate();
-
- this->m_pFr = (CMainFrame*)AfxGetApp()->m_pMainWnd;
- }
- void CYProject::DrawYCoordinate(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,"密度");
- //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);
- }
- void CYProject::YProjection(CDC *pDC)
- {
- if (::gbIsGetData)
- return;
- if (::gbDataIsEmpty)
- return;
- CRect rc;
- this->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-30,
- (rc.bottom-20)-(Databuf[i][this->m_pFr->m_pView->m_Third]*80-100),RED);
- }
- }
- }