XProject.cpp
上传用户:wangdan
上传日期:2022-06-30
资源大小:739k
文件大小:3k
- // XProject.cpp : implementation file
- //
- #include "stdafx.h"
- #include "Test1.h"
- #include "XProject.h"
- #include "MainFrm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CXProject
- extern GLfloat Databuf[ArrayOne][ArrayTwo];
- extern bool gbIsGetData;
- extern bool gbDataIsEmpty;
- IMPLEMENT_DYNCREATE(CXProject, CView)
- CXProject::CXProject()
- {
- }
- CXProject::~CXProject()
- {
- }
- BEGIN_MESSAGE_MAP(CXProject, CView)
- //{{AFX_MSG_MAP(CXProject)
- ON_WM_ERASEBKGND()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CXProject drawing
- void CXProject::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,"X轴投影-声波");
- this->DrawXCoordinate(pDC);
- this->XProjection(pDC);
- pDC->SelectObject(pOldPen);
- pDC->SelectObject(OldFont);
- delete pen;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CXProject diagnostics
- #ifdef _DEBUG
- void CXProject::AssertValid() const
- {
- CView::AssertValid();
- }
- void CXProject::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CXProject message handlers
- BOOL CXProject::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 CXProject::OnInitialUpdate()
- {
- CView::OnInitialUpdate();
-
- this->m_pFr = (CMainFrame*)AfxGetApp()->m_pMainWnd;
-
- }
- void CXProject::DrawXCoordinate(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 CXProject::XProjection(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_Second]*4+10,
- (rc.bottom-20) - (Databuf[i][this->m_pFr->m_pView->m_Third]*80-90),GREEN);
- }
- }
- }