2022-05-31 22:21:20 +08:00
|
|
|
|
// TotalView.cpp : 实现文件
|
2022-03-20 15:14:44 +08:00
|
|
|
|
//
|
2022-06-02 10:08:38 +08:00
|
|
|
|
#include <math.h>
|
2022-03-20 15:14:44 +08:00
|
|
|
|
|
|
|
|
|
#include "pch.h"
|
|
|
|
|
|
|
|
|
|
#include "MCA.h"
|
2022-05-31 22:21:20 +08:00
|
|
|
|
#include "MCADoc.h"
|
2022-03-20 15:14:44 +08:00
|
|
|
|
#include "TotalView.h"
|
2022-05-31 22:21:20 +08:00
|
|
|
|
#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)
|
2022-05-31 22:21:20 +08:00
|
|
|
|
ON_WM_PAINT()
|
|
|
|
|
ON_WM_ERASEBKGND()
|
|
|
|
|
ON_WM_LBUTTONDOWN()
|
|
|
|
|
ON_WM_RBUTTONDOWN()
|
2022-03-20 15:14:44 +08:00
|
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 22:21:20 +08:00
|
|
|
|
// CTotalView 绘图
|
2022-03-20 15:14:44 +08:00
|
|
|
|
|
2022-05-31 22:21:20 +08:00
|
|
|
|
void CTotalView::OnDraw(CDC* pDc)
|
2022-03-20 15:14:44 +08:00
|
|
|
|
{
|
2022-05-31 22:21:20 +08:00
|
|
|
|
// 背景颜色、笔颜色等设置
|
|
|
|
|
CDC MemDC;
|
2022-06-02 10:08:38 +08:00
|
|
|
|
MemDC.CreateCompatibleDC(pDc);
|
|
|
|
|
|
2022-05-31 22:21:20 +08:00
|
|
|
|
CRect rect;
|
|
|
|
|
CBitmap Bitmap, * OldBitmap;
|
2022-06-02 10:08:38 +08:00
|
|
|
|
CPen pen(PS_SOLID, 3, RGB(0, 0, 0));
|
2022-05-31 22:21:20 +08:00
|
|
|
|
CPen* oldpen = MemDC.SelectObject(&pen);
|
2022-06-02 10:08:38 +08:00
|
|
|
|
|
2022-05-31 22:21:20 +08:00
|
|
|
|
GetClientRect(&rect);
|
|
|
|
|
Bitmap.CreateCompatibleBitmap(pDc, rect.Width(), rect.Height());
|
|
|
|
|
OldBitmap = MemDC.SelectObject(&Bitmap);
|
|
|
|
|
MemDC.FillSolidRect(0, 0, rect.Width(), rect.Height(), RGB(36, 217, 163));
|
|
|
|
|
|
|
|
|
|
// 绘图
|
2022-06-02 10:08:38 +08:00
|
|
|
|
if (pView->m_sAxisMode == "Linear") {
|
|
|
|
|
MemDC.MoveTo(1, rect.Height() - pDoc->m_nChannelSmooth[0] * rect.Height() / pView->m_nLC);
|
|
|
|
|
for (int i = 0; i < 1024; i++)
|
|
|
|
|
MemDC.LineTo(2 * i + 1, rect.Height() - pDoc->m_nChannelSmooth[i] * rect.Height() / pView->m_nLC);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
MemDC.MoveTo(1, rect.Height() - log10(max(pDoc->m_nChannelSmooth[0], 1)) * rect.Height() / log10(pView->m_nLC));
|
|
|
|
|
for (int i = 0; i < 1024; i++)
|
|
|
|
|
MemDC.LineTo(2 * i + 1, rect.Height() - log10(max(pDoc->m_nChannelSmooth[i], 1)) * rect.Height() / log10(pView->m_nLC));
|
|
|
|
|
}
|
|
|
|
|
// 绘制光标竖线
|
|
|
|
|
pen.CreatePen(PS_SOLID, 5, RGB(255, 0, 0));
|
|
|
|
|
MemDC.SelectObject(&pen);
|
|
|
|
|
MemDC.MoveTo(2 * pView->m_nCursor1 + 1, 0);
|
|
|
|
|
MemDC.LineTo(2 * pView->m_nCursor1 + 1, rect.Height());
|
|
|
|
|
pen.CreatePen(PS_SOLID, 5, RGB(0, 255, 0));
|
|
|
|
|
MemDC.SelectObject(&pen);
|
|
|
|
|
MemDC.MoveTo(2 * pView->m_nCursor2 + 1, 0);
|
|
|
|
|
MemDC.LineTo(2 * pView->m_nCursor2 + 1, rect.Height());
|
|
|
|
|
|
|
|
|
|
//释放资源
|
2022-05-31 22:21:20 +08:00
|
|
|
|
MemDC.SelectObject(oldpen);
|
|
|
|
|
pen.DeleteObject();
|
2022-06-02 10:08:38 +08:00
|
|
|
|
|
|
|
|
|
pDc->BitBlt(0, 0, rect.Width(), rect.Height(), &MemDC, 0, 0, SRCCOPY);
|
|
|
|
|
MemDC.SelectObject(OldBitmap);
|
2022-05-31 22:21:20 +08:00
|
|
|
|
Bitmap.DeleteObject();
|
|
|
|
|
MemDC.DeleteDC();
|
2022-03-20 15:14:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 22:21:20 +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
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 22:21:20 +08:00
|
|
|
|
// CTotalView 消息处理程序
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CTotalView::OnPaint()
|
|
|
|
|
{
|
|
|
|
|
if (pDoc == NULL) pDoc = (CMCADoc*)GetDocument();
|
2022-06-02 10:08:38 +08:00
|
|
|
|
if (pView == NULL) pView = (CControlView*)pDoc->GetView(RUNTIME_CLASS(CControlView));
|
2022-05-31 22:21:20 +08:00
|
|
|
|
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;
|
2022-06-02 10:08:38 +08:00
|
|
|
|
if (nX < pView->m_nCursor2) {
|
|
|
|
|
pView->m_nCursor1 = nX;
|
|
|
|
|
pView->m_nCursorROI = max(pView->m_nCursor1, pView->m_nCursorROI);
|
|
|
|
|
}
|
|
|
|
|
pDoc->UpdateAllViews(NULL);
|
2022-05-31 22:21:20 +08:00
|
|
|
|
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;
|
2022-06-02 10:08:38 +08:00
|
|
|
|
if (nX > pView->m_nCursor1) {
|
|
|
|
|
pView->m_nCursor2 = nX;
|
|
|
|
|
pView->m_nCursorROI = min(pView->m_nCursor2, pView->m_nCursorROI);
|
|
|
|
|
}
|
|
|
|
|
pDoc->UpdateAllViews(NULL);
|
2022-05-31 22:21:20 +08:00
|
|
|
|
CView::OnRButtonDown(nFlags, point);
|
2022-06-02 10:08:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOL CTotalView::PreTranslateMessage(MSG* pMsg)
|
|
|
|
|
{
|
|
|
|
|
if (pDoc == NULL) pDoc = (CMCADoc*)GetDocument();
|
|
|
|
|
if (pView == NULL) pView = (CControlView*)pDoc->GetView(RUNTIME_CLASS(CControlView));
|
|
|
|
|
if (pMsg->message == WM_KEYDOWN) {
|
|
|
|
|
if (pMsg->wParam == VK_LEFT) pView->m_nCursorROI = max(pView->m_nCursor1, pView->m_nCursorROI - 1);
|
|
|
|
|
if (pMsg->wParam == VK_RIGHT) pView->m_nCursorROI = min(pView->m_nCursor2, pView->m_nCursorROI + 1);
|
|
|
|
|
if (pMsg->wParam == VK_UP) {
|
|
|
|
|
pView->m_nLC *= 2;
|
|
|
|
|
pView->m_bAutoFlag = TRUE;
|
|
|
|
|
pView->m_sRangeMode = (CString)"Manual";
|
|
|
|
|
}
|
|
|
|
|
if (pMsg->wParam == VK_DOWN) {
|
|
|
|
|
pView->m_nLC = pView->m_nLC > 1 ? pView->m_nLC / 2 : 1;
|
|
|
|
|
pView->m_bAutoFlag = TRUE;
|
|
|
|
|
pView->m_sRangeMode = (CString)"Manual";
|
|
|
|
|
}
|
|
|
|
|
pDoc->UpdateAllViews(NULL);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
return CView::PreTranslateMessage(pMsg);
|
|
|
|
|
}
|