diff --git a/ChangeLog.md b/ChangeLog.md index 53fcec7..6149fc9 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -9,4 +9,11 @@ ### 5.30 * control view +### 5.31 +* 全谱区 +* 放大区 +* 结束条件 +* 模拟信号 +* 开始、结束、暂停 + [^1]: Xiao M, Hu R, Ge L Q, et al. Study of a full-digital multi-waveform nuclear pulse signal generator[J]. Applied Radiation and Isotopes, 2022, 179: 110028. \ No newline at end of file diff --git a/MCA/ControlView.cpp b/MCA/ControlView.cpp index ccb631a..8e1e297 100644 --- a/MCA/ControlView.cpp +++ b/MCA/ControlView.cpp @@ -1,6 +1,8 @@ // ControlView.cpp: 实现文件 // +#include + #include "pch.h" #include "math.h" @@ -15,6 +17,18 @@ IMPLEMENT_DYNCREATE(CControlView, CFormView) CControlView::CControlView() : CFormView(IDD_DIALOG_CONTROL) + , m_nCond(100) + , m_nT0(0) + , m_nTime(0) + , m_nTimeStr((CString)'0') + , m_nTotalCount(0) + , m_nPartCount(0) + , m_nMaxCount(0) + , m_nRange(4) + , m_nCursor1(0) + , m_nCursor2(1023) + , m_nCursorROI(0) + , m_nCursorROICount(0) { } @@ -24,11 +38,33 @@ CControlView::~CControlView() void CControlView::DoDataExchange(CDataExchange* pDX) { - CFormView::DoDataExchange(pDX); + CFormView::DoDataExchange(pDX); + DDX_Text(pDX, IDC_COND, m_nCond); + DDX_Text(pDX, IDC_TIME, m_nTimeStr); + DDX_Text(pDX, IDC_TCOUNT, m_nTotalCount); + DDX_Text(pDX, IDC_PCOUNT, m_nPartCount); + DDX_Text(pDX, IDC_MCOUNT, m_nMaxCount); + DDX_Control(pDX, IDC_MODE, m_ComboMode); + DDX_Control(pDX, IDC_AXIS, m_ComboAxis); + DDX_Text(pDX, IDC_RANGE, m_nRange); + DDX_Text(pDX, IDC_CURSOR1, m_nCursor1); + DDX_Text(pDX, IDC_CURSOR2, m_nCursor2); + DDX_Text(pDX, IDC_CURSORROI, m_nCursorROI); + DDX_Text(pDX, IDC_CURSORROI_COUNT, m_nCursorROICount); } BEGIN_MESSAGE_MAP(CControlView, CFormView) ON_WM_SIZE() + ON_COMMAND(ID_STA_START, &CControlView::OnStaStart) + ON_COMMAND(ID_STA_STOP, &CControlView::OnStaStop) + ON_UPDATE_COMMAND_UI(ID_STA_START, &CControlView::OnUpdateStaStart) + ON_UPDATE_COMMAND_UI(ID_STA_STOP, &CControlView::OnUpdateStaStop) + ON_COMMAND(ID_STA_CLEAR, &CControlView::OnStaClear) + ON_UPDATE_COMMAND_UI(ID_STA_CLEAR, &CControlView::OnUpdateStaClear) + ON_WM_TIMER() + ON_COMMAND(ID_SIMU_CO, &CControlView::OnSimuCo) + ON_COMMAND(ID_SIMU_CS, &CControlView::OnSimuCs) + ON_COMMAND(ID_SIMU_NA, &CControlView::OnSimuNa) END_MESSAGE_MAP() @@ -50,8 +86,6 @@ void CControlView::Dump(CDumpContext& dc) const // CControlView 消息处理程序 - - void CControlView::OnSize(UINT nType, int cx, int cy) { CFormView::OnSize(nType, cx, cy); @@ -62,4 +96,131 @@ void CControlView::OnSize(UINT nType, int cx, int cy) size.cx = rect.right - rect.left; size.cy = rect.bottom - rect.top; SetScrollSizes(MM_HIMETRIC, size); // 将CScrollView的大小设置为当前客户区大小 -} \ No newline at end of file +} + +void CControlView::OnInitialUpdate() +{ + CFormView::OnInitialUpdate(); + + // 添加运行模式 + m_ComboMode.AddString((CString)"时间"); + m_ComboMode.AddString((CString)"计数"); + m_ComboMode.SetCurSel(0); + // 添加坐标轴模式 + m_ComboAxis.AddString((CString)"线性"); + m_ComboAxis.AddString((CString)"对数"); + m_ComboAxis.SetCurSel(0); + + m_Menu.LoadMenuW(IDR_MAINFRAME); + m_wndToolBar.LoadToolBar(IDR_MAINFRAME); + SetMenu(&m_Menu); +} + +void CControlView::OnUpdate(CView* /*pSender*/, LPARAM /*lHint*/, CObject* /*pHint*/) +{ +} + +double CControlView::GetMilliTime() +{ + std::chrono::milliseconds ms = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch() + ); + return ms.count() / 1000.; +} + +void CControlView::OnStaStart() +{ + // 重置结束条件 + m_nT0 = GetMilliTime(); + // 设置状态 + startFlag = FALSE; + stopFlag = TRUE; + clearFlag = FALSE; + ((CEdit*)GetDlgItem(IDC_COND))->EnableWindow(FALSE); + // 获取屏幕值至变量 + UpdateData(TRUE); + // 设置更新 + SetTimer(1, 100, NULL); +} + +void CControlView::OnUpdateStaStart(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(startFlag); +} + +void CControlView::OnStaStop() +{ + // 设置状态 + startFlag = TRUE; + stopFlag = FALSE; + clearFlag = TRUE; + ((CEdit*)GetDlgItem(IDC_COND))->EnableWindow(TRUE); + // 停止更新 + KillTimer(1); +} + +void CControlView::OnUpdateStaStop(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(stopFlag); +} + +void CControlView::OnStaClear() +{ + CMCADoc* pDoc = (CMCADoc*)GetDocument(); + // 重置 + m_nTime = 0; + m_nMaxCount = 0; + m_nPartCount = 0; + m_nTotalCount = 0; + m_nTimeStr = (CString)"0.0"; + // 获取屏幕值至变量 + UpdateData(FALSE); + // 设置曲线 + for (int i = 0; i < pDoc->m_nChannelNum; i++) + pDoc->m_nChannelCount[i] = 0; + pDoc->UpdateAllViews(NULL); +} + +void CControlView::OnUpdateStaClear(CCmdUI* pCmdUI) +{ + pCmdUI->Enable(clearFlag); +} + +void CControlView::OnTimer(UINT_PTR nIDEvent) +{ + CString tmp; + CMCADoc* pDoc = (CMCADoc*)GetDocument(); + m_nTotalCount = pDoc->GetTotal(0, 1023); + m_nMaxCount = pDoc->GetMax(0, 1023); + m_nPartCount = pDoc->GetTotal(m_nCursor1, m_nCursor2); + + m_nTime += GetMilliTime() - m_nT0; + m_nTimeStr.Format(_T("%.1f"), m_nTime); + m_nT0 = GetMilliTime(); + + m_ComboMode.GetWindowText(tmp); + if (tmp == "时间" && m_nTime >= m_nCond) OnStaStop(); + if (tmp == "计数" && m_nTotalCount >= m_nCond) OnStaStop(); + + UpdateData(FALSE); + + int n = rand() % 50 + 25; + ((CMCADoc*)GetDocument())->RandomPeak(source, n); + ((CMCADoc*)GetDocument())->UpdateAllViews(NULL); + CFormView::OnTimer(nIDEvent); +} + +void CControlView::OnSimuCo() +{ + source = (CString)"Co60"; +} + +void CControlView::OnSimuCs() +{ + source = (CString)"Cs137"; +} + +void CControlView::OnSimuNa() +{ + source = (CString)"Na22"; +} diff --git a/MCA/ControlView.h b/MCA/ControlView.h index 2c182d4..ee27ef0 100644 --- a/MCA/ControlView.h +++ b/MCA/ControlView.h @@ -1,6 +1,6 @@ #pragma once - +#include // CControlView 窗体视图 @@ -29,6 +29,45 @@ protected: DECLARE_MESSAGE_MAP() public: afx_msg void OnSize(UINT nType, int cx, int cy); + virtual void OnUpdate(CView* /*pSender*/, LPARAM /*lHint*/, CObject* /*pHint*/); + double GetMilliTime(); + + // 选择信息 + CString source = (CString)"Cs137"; + + // 光标信息 + int m_nCursor1; + int m_nCursor2; + int m_nCursorROI; + int m_nCursorROICount; + + // 侧边信息 + double m_nCond; + double m_nT0; + double m_nTime; + CString m_nTimeStr; + int m_nTotalCount; + int m_nPartCount; + int m_nMaxCount; + int m_nRange; + CComboBox m_ComboMode; + CComboBox m_ComboAxis; + virtual void OnInitialUpdate(); + + // 菜单与工具栏响应 + CMenu m_Menu; + CToolBar m_wndToolBar; + BOOL startFlag = TRUE; + BOOL stopFlag = FALSE; + BOOL clearFlag = FALSE; + afx_msg void OnStaStart(); + afx_msg void OnUpdateStaStart(CCmdUI* pCmdUI); + afx_msg void OnStaStop(); + afx_msg void OnUpdateStaStop(CCmdUI* pCmdUI); + afx_msg void OnStaClear(); + afx_msg void OnUpdateStaClear(CCmdUI* pCmdUI); + afx_msg void OnTimer(UINT_PTR nIDEvent); + afx_msg void OnSimuCo(); + afx_msg void OnSimuCs(); + afx_msg void OnSimuNa(); }; - - diff --git a/MCA/DetailView.cpp b/MCA/DetailView.cpp index 42c8546..9fdec91 100644 --- a/MCA/DetailView.cpp +++ b/MCA/DetailView.cpp @@ -6,6 +6,7 @@ #include "MCA.h" #include "MCADoc.h" #include "DetailView.h" +#include "ControlView.h" // CDetailView @@ -14,7 +15,6 @@ IMPLEMENT_DYNCREATE(CDetailView, CView) CDetailView::CDetailView() { - } CDetailView::~CDetailView() @@ -22,16 +22,52 @@ CDetailView::~CDetailView() } BEGIN_MESSAGE_MAP(CDetailView, CView) -// ON_WM_PAINT() + ON_WM_PAINT() + ON_WM_ERASEBKGND() + ON_WM_LBUTTONDOWN() + ON_WM_RBUTTONDOWN() END_MESSAGE_MAP() // CDetailView ͼ -void CDetailView::OnDraw(CDC* pDC) +void CDetailView::OnDraw(CDC* pDc) { - CDocument* pDoc = GetDocument(); - // TODO: ڴӻƴ + // ȡ + 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; + // + CRect rect; + GetClientRect(&rect); + ZF = rect.Width() / (R - L + 1.); + + // ɫɫ + CDC MemDC; + CBitmap Bitmap, * OldBitmap; + CPen pen(PS_SOLID, 2, RGB(255, 255, 255)); + 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(119, 7, 243)); + + // ͼ + MemDC.MoveTo(1, rect.Height() - pDoc->m_nChannelCount[L]); + for (int i = L; i <= R; i++) + MemDC.LineTo((i - L) * ZF, rect.Height() - pDoc->m_nChannelCount[i]); + + //ͷԴ + pDc->BitBlt(0, 0, rect.Width(), rect.Width(), &MemDC, 0, 0, SRCCOPY); + MemDC.SelectObject(oldpen); + MemDC.SelectObject(OldBitmap); + pen.DeleteObject(); + Bitmap.DeleteObject(); + MemDC.DeleteDC(); } @@ -53,3 +89,51 @@ void CDetailView::Dump(CDumpContext& dc) const // CDetailView Ϣ + + +void CDetailView::OnPaint() +{ + if (pDoc == NULL) pDoc = (CMCADoc*)GetDocument(); + CPaintDC dc(this); // device context for painting + OnPrepareDC(&dc); + OnDraw(&dc); +} + +BOOL CDetailView::OnEraseBkgnd(CDC* pDC) +{ + return TRUE; +} + +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; + pView->m_nCursorROICount = pDoc->m_nChannelCount[nX]; + + CPen pen; + CDC* pDC = GetDC(); + pen.CreatePen(PS_SOLID, 5, RGB(255, 180, 20)); + CPen* oldpen = pDC->SelectObject(&pen); + CRect rect; + GetClientRect(&rect); + pDC->SetROP2(R2_XORPEN); // + pDC->MoveTo(point.x, 0); //ƹ + pDC->LineTo(point.x, rect.Height()); + pDC->SelectObject(oldpen); + pen.DeleteObject(); + + CView::OnLButtonDown(nFlags, point); +} + + +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; + + CView::OnRButtonDown(nFlags, point); +} diff --git a/MCA/DetailView.h b/MCA/DetailView.h index d2e0aeb..8e55f02 100644 --- a/MCA/DetailView.h +++ b/MCA/DetailView.h @@ -1,6 +1,9 @@ #pragma once #include +#include "MCADoc.h" +#include "ControlView.h" + class CDetailView : public CView { @@ -26,5 +29,11 @@ protected: protected: DECLARE_MESSAGE_MAP() public: -// afx_msg void OnPaint(); + double ZF = 1.0; + CMCADoc* pDoc = nullptr; + CControlView* pView = nullptr; + afx_msg void OnPaint(); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnRButtonDown(UINT nFlags, CPoint point); }; diff --git a/MCA/MCA.rc b/MCA/MCA.rc index d76ac03..5832fb6 100644 Binary files a/MCA/MCA.rc and b/MCA/MCA.rc differ diff --git a/MCA/MCA.vcxproj b/MCA/MCA.vcxproj index 423c4aa..44191c7 100644 --- a/MCA/MCA.vcxproj +++ b/MCA/MCA.vcxproj @@ -221,9 +221,20 @@ + + + + + + + + + + + diff --git a/MCA/MCA.vcxproj.filters b/MCA/MCA.vcxproj.filters index 780b105..ce94177 100644 --- a/MCA/MCA.vcxproj.filters +++ b/MCA/MCA.vcxproj.filters @@ -110,5 +110,38 @@ 资源文件 + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + + + 资源文件 + \ No newline at end of file diff --git a/MCA/MCADoc.cpp b/MCA/MCADoc.cpp index bf41ad0..1b59242 100644 --- a/MCA/MCADoc.cpp +++ b/MCA/MCADoc.cpp @@ -37,7 +37,7 @@ CMCADoc::CMCADoc() noexcept FILE *stream_tmp; int channel_id, channel_count; - srand((unsigned)time(NULL)); + srand((unsigned)time(0)); m_nChannelCount = new int[m_nChannelNum]; for (int i = 0; i < m_nChannelNum; i++) m_nChannelCount[i] = 0; @@ -85,6 +85,7 @@ BOOL CMCADoc::OnNewDocument() // TODO: 在此添加重新初始化代码 // (SDI 文档将重用该文档) + SetTitle(TEXT("MultiChannel Analyzer")); return TRUE; } @@ -168,23 +169,58 @@ void CMCADoc::Dump(CDumpContext& dc) const } #endif //_DEBUG - // CMCADoc 命令 -double CMCADoc::uniform() +double CMCADoc::Uniform() { int x = rand(); - double y = (float)(x % 100) / 100; + double y = (x % 10000) / 10000.0; return y; } -void CMCADoc::random_peaks(std::string name) +void CMCADoc::RandomPeak(CString name, int n) { - int K; - double eps = uniform(); + __int64 K; + double eps; - if (name == "Co60") K = std::lower_bound(es_Co60, es_Co60 + 1024, eps) - es_Co60; - else if (name == "Cs137") K = std::lower_bound(es_Cs137, es_Cs137 + 1024, eps) - es_Cs137; - else K = std::lower_bound(es_Na22, es_Na22 + 1024, eps) - es_Na22; + for (int i = 0; i < n; i++) { + eps = Uniform(); - m_nChannelCount[K] += 1; -} \ No newline at end of file + if (name == "Co60") K = std::lower_bound(es_Co60, es_Co60 + 1024, eps) - es_Co60; + else if (name == "Cs137") K = std::lower_bound(es_Cs137, es_Cs137 + 1024, eps) - es_Cs137; + else K = std::lower_bound(es_Na22, es_Na22 + 1024, eps) - es_Na22; + + m_nChannelCount[K] += 1; + } +} + +int CMCADoc::GetTotal(int L, int R) +{ + int cSum = 0; + for (int i = L; i <= min(m_nChannelNum-1, R); i++) cSum += m_nChannelCount[i]; + return cSum; +} + +int CMCADoc::GetMax(int L, int R) +{ + int cMax = 0; + for (int i = L; i <= min(m_nChannelNum - 1, R); i++) + if (m_nChannelCount[i] > cMax) + cMax = m_nChannelCount[i]; + return cMax; +} + + +CView* CMCADoc::GetView(CRuntimeClass* pClass) +{ + CView* pView{}; + POSITION pos = GetFirstViewPosition(); + while (pos != NULL) { + pView = GetNextView(pos); + if (pView->IsKindOf(pClass)) break; + } + if (!pView->IsKindOf(pClass)) { + AfxMessageBox((CString)"Cannot Locate the View!"); + return nullptr; + } + return pView; +} diff --git a/MCA/MCADoc.h b/MCA/MCADoc.h index 7f5f49b..2a6b56a 100644 --- a/MCA/MCADoc.h +++ b/MCA/MCADoc.h @@ -26,10 +26,8 @@ private: // 操作 public: - void random_peaks(std::string name); - -private: - double uniform(); + void RandomPeak(CString name, int n); + double Uniform(); // 重写 public: @@ -59,4 +57,8 @@ protected: // 用于为搜索处理程序设置搜索内容的 Helper 函数 void SetSearchContent(const CString& value); #endif // SHARED_HANDLERS +public: + int GetTotal(int L, int R); + int GetMax(int L, int R); + CView* GetView(CRuntimeClass* pClass); }; diff --git a/MCA/MainFrm.cpp b/MCA/MainFrm.cpp index b06cbc2..0f83fbb 100644 --- a/MCA/MainFrm.cpp +++ b/MCA/MainFrm.cpp @@ -67,7 +67,10 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); + MoveWindow(0, 0, 2386, 1200); + CenterWindow(); + OnLoadToolBarIcon(); return 0; } @@ -79,16 +82,17 @@ BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/, WS_CHILD | WS_VISIBLE, AFX_IDW_PANE_FIRST)); // 左侧窗口创建视图,第0行第0列 VERIFY(m_wndSplitter.CreateView(0, 0, - RUNTIME_CLASS(CControlView), CSize(360, 0), pContext)); + RUNTIME_CLASS(CControlView), CSize(300, 0), pContext)); // 右侧窗口上下拆分,2行1列 - VERIFY(m_wndSplitter_2.CreateStatic(&m_wndSplitter, 2, 1, + VERIFY(m_wndSplitter2.CreateStatic(&m_wndSplitter, 2, 1, WS_CHILD | WS_VISIBLE, m_wndSplitter.IdFromRowCol(0, 1))); // 右上窗口创建视图,第0行第0列 - VERIFY(m_wndSplitter_2.CreateView(0, 0, - RUNTIME_CLASS(CTotalView), CSize(0, 300), pContext)); + VERIFY(m_wndSplitter2.CreateView(0, 0, + RUNTIME_CLASS(CTotalView), CSize(2086, 400), pContext)); // 右下窗口创建视图,第1行第0列 - VERIFY(m_wndSplitter_2.CreateView(1, 0, - RUNTIME_CLASS(CDetailView), CSize(0, 0), pContext)); + VERIFY(m_wndSplitter2.CreateView(1, 0, + RUNTIME_CLASS(CDetailView), CSize(2086, 0), pContext)); + return TRUE; } @@ -96,9 +100,8 @@ BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if( !CFrameWnd::PreCreateWindow(cs) ) return FALSE; - // TODO: 在此处通过修改 - // CREATESTRUCT cs 来修改窗口类或样式 - + cs.style &= ~WS_THICKFRAME; + cs.style &= ~WS_MAXIMIZEBOX; return TRUE; } @@ -119,3 +122,33 @@ void CMainFrame::Dump(CDumpContext& dc) const // CMainFrame 消息处理程序 + + +void CMainFrame::OnLoadToolBarIcon() +{ + HICON icon; + m_imgList.Create(50, 50, TRUE | ILC_COLOR32, 10, 0); + + icon = AfxGetApp()->LoadIconW(IDI_START); + m_imgList.Add(icon); + icon = AfxGetApp()->LoadIconW(IDI_STOP); + m_imgList.Add(icon); + icon = AfxGetApp()->LoadIconW(IDI_CLEAR); + m_imgList.Add(icon); + icon = AfxGetApp()->LoadIconW(IDI_FOLDER); + m_imgList.Add(icon); + icon = AfxGetApp()->LoadIconW(IDI_SAVE); + m_imgList.Add(icon); + icon = AfxGetApp()->LoadIconW(IDI_LEFT); + m_imgList.Add(icon); + icon = AfxGetApp()->LoadIconW(IDI_RIGHT); + m_imgList.Add(icon); + icon = AfxGetApp()->LoadIconW(IDI_UP); + m_imgList.Add(icon); + icon = AfxGetApp()->LoadIconW(IDI_DOWN); + m_imgList.Add(icon); + icon = AfxGetApp()->LoadIconW(IDI_CLOSE); + m_imgList.Add(icon); + + m_wndToolBar.GetToolBarCtrl().SetImageList(&m_imgList); +} diff --git a/MCA/MainFrm.h b/MCA/MainFrm.h index af188b2..0129579 100644 --- a/MCA/MainFrm.h +++ b/MCA/MainFrm.h @@ -14,7 +14,7 @@ protected: // 仅从序列化创建 // 特性 protected: CSplitterWnd m_wndSplitter; - CSplitterWnd m_wndSplitter_2; + CSplitterWnd m_wndSplitter2; public: // 操作 @@ -42,6 +42,9 @@ protected: afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); DECLARE_MESSAGE_MAP() +public: + void OnLoadToolBarIcon(); + CImageList m_imgList; }; diff --git a/MCA/Resource.h b/MCA/Resource.h index 3190013..4d38bae 100644 --- a/MCA/Resource.h +++ b/MCA/Resource.h @@ -6,11 +6,34 @@ #define IDP_OLE_INIT_FAILED 100 #define IDR_MAINFRAME 128 #define IDR_MCATYPE 130 -#define IDD_DIALOG1 310 #define IDD_DIALOG_CONTROL 310 -#define IDC_TREE1 1010 +#define IDI_CLOSE 313 +#define IDI_DOWN 314 +#define IDI_FOLDER 315 +#define IDI_LEFT 316 +#define IDI_RIGHT 318 +#define IDI_SAVE 319 +#define IDI_START 320 +#define IDI_STOP 321 +#define IDI_UP 322 +#define IDI_CLEAR 323 #define IDC_MFCSHELLTREE1 1013 -#define IDC_MFCMASKEDEDIT1 1015 +#define IDC_MODE 1017 +#define IDC_COND 1018 +#define IDC_TIME 1019 +#define IDC_TCOUNT 1020 +#define IDC_BCHA 1021 +#define IDC_ECHA 1022 +#define IDC_CURSOR1 1023 +#define IDC_CURSORROI_COUNT 1024 +#define IDC_RANGE 1025 +#define IDC_MCOUNT 1026 +#define IDC_AXIS 1027 +#define IDC_CURSOR1_COUNT 1028 +#define IDC_CURSOR2 1029 +#define IDC_CURSOR2_COUNT 1030 +#define IDC_CURSORROI 1031 +#define IDC_PCOUNT 1032 #define ID_32786 32786 #define ID_32787 32787 #define ID_32788 32788 @@ -29,25 +52,45 @@ #define ID_32801 32801 #define ID_BUTTON32803 32803 #define ID_BUTTON32804 32804 -#define ID_BUTTON32805 32805 -#define ID_BUTTON32806 32806 -#define ID_BUTTON32807 32807 +#define ID_ARROW_RIGHT 32805 +#define ID_ARROW_UP 32806 +#define ID_ARROW_DOWN 32807 #define ID_BUTTON32808 32808 -#define ID_BUTTON32809 32809 -#define ID_BUTTON32810 32810 -#define ID_BUTTON32811 32811 +#define ID_STA_START 32809 +#define ID_STA_STOP 32811 #define ID_32812 32812 #define ID_32813 32813 #define ID_32814 32814 #define ID_32815 32815 +#define ID_ARROW_LEFT 32817 +#define ID_32818 32818 +#define ID_32819 32819 +#define ID_32820 32820 +#define ID_AXIS_LINEAR 32821 +#define ID_AXIS_LOG 32822 +#define ID_RANGE_AUTO 32823 +#define ID_RANGE_D4 32826 +#define ID_RANGE_D2 32827 +#define ID_RANGE_M2 32828 +#define ID_RANGE_M4 32829 +#define ID_32830 32830 +#define ID_SIMU_CO 32831 +#define ID_SIMU_CS 32832 +#define ID_SIMU_NA 32833 +#define ID_DATA_ORIGIN 32834 +#define ID_DATA_3 32835 +#define ID_DATA_5 32836 +#define ID_STA_CLEAR 32837 +#define ID_32838 32838 +#define ID_32839 32839 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 313 -#define _APS_NEXT_COMMAND_VALUE 32816 -#define _APS_NEXT_CONTROL_VALUE 1016 +#define _APS_NEXT_RESOURCE_VALUE 324 +#define _APS_NEXT_COMMAND_VALUE 32840 +#define _APS_NEXT_CONTROL_VALUE 1019 #define _APS_NEXT_SYMED_VALUE 310 #endif #endif diff --git a/MCA/TotalView.cpp b/MCA/TotalView.cpp index 4a75fe0..d834c3b 100644 --- a/MCA/TotalView.cpp +++ b/MCA/TotalView.cpp @@ -1,11 +1,12 @@ -// TotalView.cpp : ʵļ +// TotalView.cpp : 实现文件 // #include "pch.h" #include "MCA.h" +#include "MCADoc.h" #include "TotalView.h" - +#include "ControlView.h" // CTotalView @@ -21,19 +22,46 @@ CTotalView::~CTotalView() } BEGIN_MESSAGE_MAP(CTotalView, CView) + ON_WM_PAINT() + ON_WM_ERASEBKGND() + ON_WM_LBUTTONDOWN() + ON_WM_RBUTTONDOWN() END_MESSAGE_MAP() -// CTotalView ͼ +// CTotalView 绘图 -void CTotalView::OnDraw(CDC* pDC) +void CTotalView::OnDraw(CDC* pDc) { - CDocument* pDoc = GetDocument(); - // TODO: ڴӻƴ + // 背景颜色、笔颜色等设置 + 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(); } -// CTotalView +// CTotalView 诊断 #ifdef _DEBUG void CTotalView::AssertValid() const @@ -50,4 +78,37 @@ void CTotalView::Dump(CDumpContext& dc) const #endif //_DEBUG -// CTotalView Ϣ +// 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); +} \ No newline at end of file diff --git a/MCA/TotalView.h b/MCA/TotalView.h index 4d316f8..595ecf7 100644 --- a/MCA/TotalView.h +++ b/MCA/TotalView.h @@ -1,6 +1,9 @@ #pragma once #include +#include "MCADoc.h" +#include "ControlView.h" + class CTotalView : public CView { @@ -25,4 +28,11 @@ protected: // ɵϢӳ亯 protected: DECLARE_MESSAGE_MAP() +public: + CMCADoc* pDoc = nullptr; + CControlView* pView = nullptr; + afx_msg void OnPaint(); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnRButtonDown(UINT nFlags, CPoint point); }; diff --git a/MCA/res/Toolbar.bmp b/MCA/res/Toolbar.bmp index 45784c7..a3def61 100644 Binary files a/MCA/res/Toolbar.bmp and b/MCA/res/Toolbar.bmp differ diff --git a/MCA/res/clear.ico b/MCA/res/clear.ico new file mode 100644 index 0000000..5160b82 Binary files /dev/null and b/MCA/res/clear.ico differ diff --git a/MCA/res/close.ico b/MCA/res/close.ico new file mode 100644 index 0000000..df3d896 Binary files /dev/null and b/MCA/res/close.ico differ diff --git a/MCA/res/down.ico b/MCA/res/down.ico new file mode 100644 index 0000000..b3c00fe Binary files /dev/null and b/MCA/res/down.ico differ diff --git a/MCA/res/folder.ico b/MCA/res/folder.ico new file mode 100644 index 0000000..30dab5c Binary files /dev/null and b/MCA/res/folder.ico differ diff --git a/MCA/res/left.ico b/MCA/res/left.ico new file mode 100644 index 0000000..0d20ba2 Binary files /dev/null and b/MCA/res/left.ico differ diff --git a/MCA/res/right.ico b/MCA/res/right.ico new file mode 100644 index 0000000..128ee55 Binary files /dev/null and b/MCA/res/right.ico differ diff --git a/MCA/res/save.ico b/MCA/res/save.ico new file mode 100644 index 0000000..c7b4e8c Binary files /dev/null and b/MCA/res/save.ico differ diff --git a/MCA/res/start.ico b/MCA/res/start.ico new file mode 100644 index 0000000..45b8035 Binary files /dev/null and b/MCA/res/start.ico differ diff --git a/MCA/res/stop.ico b/MCA/res/stop.ico new file mode 100644 index 0000000..589a127 Binary files /dev/null and b/MCA/res/stop.ico differ diff --git a/MCA/res/up.ico b/MCA/res/up.ico new file mode 100644 index 0000000..0fcffa9 Binary files /dev/null and b/MCA/res/up.ico differ