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

146 lines
3.9 KiB
C++
Raw Normal View History

2022-03-20 15:14:44 +08:00
// ControlView.cpp: 实现文件
//
#include "pch.h"
#include "MCA.h"
#include "MCADoc.h"
#include "MainFrm.h"
#include "DetailView.h"
2022-03-20 15:14:44 +08:00
#include "ControlView.h"
// CControlView
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_nLC(4)
2022-06-03 01:47:52 +08:00
, m_nWidth(1024)
, m_nCursor1(0)
, m_nCursor2(1023)
, m_nCursorROI(0)
2022-06-04 01:40:27 +08:00
, m_nCursor1Count(0)
, m_nCursor2Count(0)
, m_nCursorROICount(0) {
2022-03-20 15:14:44 +08:00
}
CControlView::~CControlView() {
2022-03-20 15:14:44 +08:00
}
void CControlView::DoDataExchange(CDataExchange* 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_Text(pDX, IDC_RANGE, m_nLC);
2022-06-03 01:47:52 +08:00
DDX_Text(pDX, IDC_WIDTH, m_nWidth);
DDX_Text(pDX, IDC_CURSOR1, m_nCursor1);
DDX_Text(pDX, IDC_CURSOR2, m_nCursor2);
DDX_Text(pDX, IDC_CURSORROI, m_nCursorROI);
2022-06-04 01:40:27 +08:00
DDX_Text(pDX, IDC_CURSOR1_COUNT, m_nCursor1Count);
DDX_Text(pDX, IDC_CURSOR2_COUNT, m_nCursor2Count);
DDX_Text(pDX, IDC_CURSORROI_COUNT, m_nCursorROICount);
DDX_Control(pDX, IDC_MODE, m_ComboMode);
DDX_Control(pDX, IDC_AXIS, m_ComboAxis);
DDX_Control(pDX, IDC_SOURCE, m_ComboSource);
2022-03-20 15:14:44 +08:00
}
BEGIN_MESSAGE_MAP(CControlView, CFormView)
ON_WM_SIZE()
ON_CBN_SELCHANGE(IDC_SOURCE, &CControlView::OnCbnSelchangeSource)
ON_CBN_SELCHANGE(IDC_MODE, &CControlView::OnCbnSelchangeMode)
ON_CBN_SELCHANGE(IDC_AXIS, &CControlView::OnCbnSelchangeAxis)
END_MESSAGE_MAP()
2022-03-20 15:14:44 +08:00
// CControlView 诊断
#ifdef _DEBUG
void CControlView::AssertValid() const {
2022-03-20 15:14:44 +08:00
CFormView::AssertValid();
}
#ifndef _WIN32_WCE
void CControlView::Dump(CDumpContext& dc) const {
2022-03-20 15:14:44 +08:00
CFormView::Dump(dc);
}
#endif
#endif //_DEBUG
void CControlView::SetCond(BOOL flag) {
((CEdit*)GetDlgItem(IDC_COND))->EnableWindow(flag);
2022-06-02 14:57:51 +08:00
}
2022-03-20 15:14:44 +08:00
// CControlView 消息处理程序
void CControlView::OnSize(UINT nType, int cx, int cy) {
CFormView::OnSize(nType, cx, cy);
CRect rect;
GetClientRect(&rect); // 获取当前客户区view大小
CSize size;
size.cx = rect.right - rect.left;
size.cy = rect.bottom - rect.top;
SetScrollSizes(MM_HIMETRIC, size); // 将CScrollView的大小设置为当前客户区大小
}
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_ComboSource.AddString((CString)"Co60");
m_ComboSource.AddString((CString)"Cs137");
m_ComboSource.AddString((CString)"Na22");
m_ComboSource.SetCurSel(1);
}
void CControlView::OnUpdate(CView* /*pSender*/, LPARAM /*lHint*/, CObject* /*pHint*/) {
}
void CControlView::OnCbnSelchangeSource() {
CString tmp;
CMainFrame* pFrame = (CMainFrame*)GetParentFrame();
m_ComboSource.GetWindowText(tmp);
if (tmp != m_sSource) {
pFrame->OnStaStop();
pFrame->OnStaClear();
}
if (tmp == "Cs137") pFrame->OnSimuCsOpt();
else if (tmp == "Co60") pFrame->OnSimuCoOpt();
else pFrame->OnSimuNaOpt();
}
void CControlView::OnCbnSelchangeMode() {
CString tmp;
CMainFrame* pFrame = (CMainFrame*)GetParentFrame();
m_ComboMode.GetWindowText(tmp);
if (tmp == "时间") m_sMode = "Time";
else m_sMode = "Count";
}
void CControlView::OnCbnSelchangeAxis() {
CString tmp;
CMainFrame* pFrame = (CMainFrame*)GetParentFrame();
m_ComboAxis.GetWindowText(tmp);
if (tmp == "对数") pFrame->OnAxisLog();
else pFrame->OnAxisLinear();
}