// ControlView.cpp: 实现文件 // #include "pch.h" #include "MCA.h" #include "MCADoc.h" #include "MainFrm.h" #include "DetailView.h" #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) , m_nWidth(1024) , m_nCursor1(0) , m_nCursor2(1023) , m_nCursorROI(0) , m_nCursor1Count(0) , m_nCursor2Count(0) , m_nCursorROICount(0) { } CControlView::~CControlView() { } 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); 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); 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); } 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() // CControlView 诊断 #ifdef _DEBUG void CControlView::AssertValid() const { CFormView::AssertValid(); } #ifndef _WIN32_WCE void CControlView::Dump(CDumpContext& dc) const { CFormView::Dump(dc); } #endif #endif //_DEBUG void CControlView::SetCond(BOOL flag) { ((CEdit*)GetDlgItem(IDC_COND))->EnableWindow(flag); } // 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(); }