This repository has been archived on 2022-07-04. You can view files and clone it, but cannot push or open issues or pull requests.
Multichannel-Analyzer/MCA/TotalView.cpp

114 lines
2.3 KiB
C++
Raw Normal View History

// TotalView.cpp : 实现文件
2022-03-20 15:14:44 +08:00
//
#include "pch.h"
#include "MCA.h"
#include "MCADoc.h"
2022-03-20 15:14:44 +08:00
#include "TotalView.h"
#include "ControlView.h"
2022-03-20 15:14:44 +08:00
// CTotalView
IMPLEMENT_DYNCREATE(CTotalView, CView)
CTotalView::CTotalView()
{
}
CTotalView::~CTotalView()
{
}
BEGIN_MESSAGE_MAP(CTotalView, CView)
ON_WM_PAINT()
ON_WM_ERASEBKGND()
ON_WM_LBUTTONDOWN()
ON_WM_RBUTTONDOWN()
2022-03-20 15:14:44 +08:00
END_MESSAGE_MAP()
// CTotalView 绘图
2022-03-20 15:14:44 +08:00
void CTotalView::OnDraw(CDC* pDc)
2022-03-20 15:14:44 +08:00
{
// 背景颜色、笔颜色等设置
CDC MemDC;
CRect rect;
CBitmap Bitmap, * OldBitmap;
CPen pen(PS_SOLID, 2, RGB(0, 0, 0));
CPen* oldpen = MemDC.SelectObject(&pen);
GetClientRect(&rect);
MemDC.CreateCompatibleDC(pDc);
Bitmap.CreateCompatibleBitmap(pDc, rect.Width(), rect.Height());
OldBitmap = MemDC.SelectObject(&Bitmap);
MemDC.FillSolidRect(0, 0, rect.Width(), rect.Height(), RGB(36, 217, 163));
// 绘图
MemDC.MoveTo(1, rect.Height() - pDoc->m_nChannelCount[0]);
for (int i = 0; i < pDoc->m_nChannelNum; i++)
MemDC.LineTo(2 * i + 1, rect.Height() - pDoc->m_nChannelCount[i]);
//释放资源   
pDc->BitBlt(0, 0, rect.Width(), rect.Height(), &MemDC, 0, 0, SRCCOPY);
MemDC.SelectObject(oldpen);
MemDC.SelectObject(OldBitmap);
pen.DeleteObject();
Bitmap.DeleteObject();
MemDC.DeleteDC();
2022-03-20 15:14:44 +08:00
}
// CTotalView 诊断
2022-03-20 15:14:44 +08:00
#ifdef _DEBUG
void CTotalView::AssertValid() const
{
CView::AssertValid();
}
#ifndef _WIN32_WCE
void CTotalView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
#endif
#endif //_DEBUG
// CTotalView 消息处理程序
void CTotalView::OnPaint()
{
if (pDoc == NULL) pDoc = (CMCADoc*)GetDocument();
CPaintDC dc(this); // device context for painting
OnPrepareDC(&dc);
OnDraw(&dc);
}
BOOL CTotalView::OnEraseBkgnd(CDC* pDC)
{
return TRUE;
}
void CTotalView::OnLButtonDown(UINT nFlags, CPoint point)
{
if (pDoc == NULL) pDoc = (CMCADoc*)GetDocument();
if (pView == NULL) pView = (CControlView*)pDoc->GetView(RUNTIME_CLASS(CControlView));
int nX = (point.x - 1) / 2;
if (nX < pView->m_nCursor2) pView->m_nCursor1 = nX;
CView::OnLButtonDown(nFlags, point);
}
void CTotalView::OnRButtonDown(UINT nFlags, CPoint point)
{
if (pDoc == NULL) pDoc = (CMCADoc*)GetDocument();
if (pView == NULL) pView = (CControlView*)pDoc->GetView(RUNTIME_CLASS(CControlView));
int nX = (point.x - 1) / 2;
if (nX > pView->m_nCursor1) pView->m_nCursor2 = nX;
CView::OnRButtonDown(nFlags, point);
}