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/DetailView.cpp

137 lines
3.6 KiB
C++
Raw Normal View History

2022-03-20 15:14:44 +08:00
// DetailView.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD>
//
#include "pch.h"
#include "MCA.h"
#include "MCADoc.h"
#include "DetailView.h"
#include "ControlView.h"
2022-03-20 15:14:44 +08:00
// CDetailView
IMPLEMENT_DYNCREATE(CDetailView, CView)
2022-06-03 13:36:34 +08:00
CDetailView::CDetailView() {
2022-03-20 15:14:44 +08:00
}
2022-06-03 13:36:34 +08:00
CDetailView::~CDetailView() {
2022-03-20 15:14:44 +08:00
}
BEGIN_MESSAGE_MAP(CDetailView, CView)
ON_WM_PAINT()
ON_WM_ERASEBKGND()
ON_WM_LBUTTONDOWN()
ON_WM_RBUTTONDOWN()
2022-03-20 15:14:44 +08:00
END_MESSAGE_MAP()
// CDetailView <20><>ͼ
2022-06-03 13:36:34 +08:00
void CDetailView::OnDraw(CDC* pDc) {
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
int L, R;
if (pDoc == NULL) pDoc = (CMCADoc*)GetDocument();
if (pView == NULL) pView = (CControlView*)pDoc->GetView(RUNTIME_CLASS(CControlView));
L = pView->m_nCursor1;
R = pView->m_nCursor2;
// <20><><EFBFBD><EFBFBD>
CRect rect;
GetClientRect(&rect);
ZF = rect.Width() / (R - L + 1.);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CDC MemDC;
MemDC.CreateCompatibleDC(pDc);
CBitmap Bitmap, * OldBitmap;
2022-06-03 21:51:15 +08:00
CPen linePen(PS_SOLID, 3, RGB(255, 255, 255));
CPen cursorPen(PS_SOLID, 5, RGB(0, 255, 0));
MemDC.SelectObject(&linePen);
Bitmap.CreateCompatibleBitmap(pDc, rect.Width(), rect.Height());
OldBitmap = MemDC.SelectObject(&Bitmap);
MemDC.FillSolidRect(0, 0, rect.Width(), rect.Height(), RGB(119, 7, 243));
// <20><>ͼ
int nMaxCount = pDoc->GetMax(L, R) ? pDoc->GetMax(L, R) * 5 / 4 : 1;
int nX = (pView->m_nCursorROI - pView->m_nCursor1) * ZF;
if (pView->m_sAxisMode == "Linear") {
MemDC.MoveTo(1, rect.Height() - pDoc->m_nChannelSmooth[L] * rect.Height() / nMaxCount);
for (int i = L; i <= R; i++)
MemDC.LineTo((i - L) * ZF, rect.Height() - pDoc->m_nChannelSmooth[i] * rect.Height() / nMaxCount);
}
else {
MemDC.MoveTo(1, rect.Height() - log10(max(pDoc->m_nChannelSmooth[L], 1)) * rect.Height() / log10(nMaxCount));
for (int i = L; i <= R; i++)
MemDC.LineTo((i - L) * ZF, rect.Height() - log10(max(pDoc->m_nChannelSmooth[i], 1)) * rect.Height() / log10(nMaxCount));
}
// <20><><EFBFBD>ƹ<EFBFBD><C6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-06-03 21:51:15 +08:00
linePen.DeleteObject();
CPen* oldpen = MemDC.SelectObject(&cursorPen);
MemDC.MoveTo(nX, 0);
MemDC.LineTo(nX, rect.Height());
//<2F>ͷ<EFBFBD><CDB7><EFBFBD>Դ
pDc->BitBlt(0, 0, rect.Width(), rect.Width(), &MemDC, 0, 0, SRCCOPY);
MemDC.SelectObject(oldpen);
MemDC.SelectObject(OldBitmap);
2022-06-03 21:51:15 +08:00
cursorPen.DeleteObject();
Bitmap.DeleteObject();
MemDC.DeleteDC();
2022-03-20 15:14:44 +08:00
}
// CDetailView <20><><EFBFBD><EFBFBD>
#ifdef _DEBUG
2022-06-03 13:36:34 +08:00
void CDetailView::AssertValid() const {
2022-03-20 15:14:44 +08:00
CView::AssertValid();
}
#ifndef _WIN32_WCE
2022-06-03 13:36:34 +08:00
void CDetailView::Dump(CDumpContext& dc) const {
2022-03-20 15:14:44 +08:00
CView::Dump(dc);
}
#endif
#endif //_DEBUG
// CDetailView <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-06-03 13:36:34 +08:00
void CDetailView::OnPaint() {
if (pDoc == NULL) pDoc = (CMCADoc*)GetDocument();
if (pView == NULL) pView = (CControlView*)pDoc->GetView(RUNTIME_CLASS(CControlView));
CPaintDC dc(this); // device context for painting
OnPrepareDC(&dc);
OnDraw(&dc);
}
2022-06-03 13:36:34 +08:00
BOOL CDetailView::OnEraseBkgnd(CDC* pDC) {
return TRUE;
}
2022-06-03 13:36:34 +08:00
void CDetailView::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 / ZF + pView->m_nCursor1;
pView->m_nCursorROI = nX;
2022-06-03 01:26:26 +08:00
pView->m_nCursorROICount = pDoc->m_nChannelCount[nX];
pView->UpdateData(FALSE);
pDoc->UpdateAllViews(NULL);
CView::OnLButtonDown(nFlags, point);
}
2022-06-03 13:36:34 +08:00
void CDetailView::OnRButtonDown(UINT nFlags, CPoint point) {
if (pDoc == NULL) pDoc = (CMCADoc*)GetDocument();
if (pView == NULL) pView = (CControlView*)pDoc->GetView(RUNTIME_CLASS(CControlView));
pView->m_nCursor1 = 0;
pView->m_nCursor2 = 1023;
2022-06-04 01:40:27 +08:00
pView->m_nCursor1Count = pDoc->m_nChannelCount[0];
pView->m_nCursor2Count = pDoc->m_nChannelCount[1023];
2022-06-03 01:47:52 +08:00
pView->m_nWidth = 1024;
pView->UpdateData(FALSE);
pDoc->UpdateAllViews(NULL);
CView::OnRButtonDown(nFlags, point);
}