// StatisticsDlg.cpp : implementation file // #include "stdafx.h" #include "imgconvw.h" #include "StatisticsDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CStatisticsDlg dialog CStatisticsDlg::CStatisticsDlg(LImageViewer *pImageViewer, CWnd* pParent /*=NULL*/) : CDialog(CStatisticsDlg::IDD, pParent) { m_pImageViewer = pImageViewer; //{{AFX_DATA_INIT(CStatisticsDlg) m_uActionCounts = 0; m_strFreeze = _T(""); m_strCellSelect = _T(""); m_uCellCount = 0; m_ConBBounds = 0; m_ConLBounds = 0; m_ConRBounds = 0; m_ConTBounds = 0; m_uColPosition = 0; m_uRowPosition = 0; m_uCellBBounds = 0.0f; m_uCellLBounds = 0.0f; m_uCellRBounds = 0.0f; m_uCellTBounds = 0.0f; //}}AFX_DATA_INIT } void CStatisticsDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CStatisticsDlg) DDX_Control(pDX, IDCMB_STATS_INDEX, m_cmbComIndex); DDX_Text(pDX, IDEDT_STATS_ACTIONCOUNT, m_uActionCounts); DDX_Text(pDX, IDEDT_STATS_CELL_FRZ, m_strFreeze); DDX_Text(pDX, IDEDT_STATS_CELL_SEL, m_strCellSelect); DDX_Text(pDX, IDEDT_STATS_CELLCOUNT, m_uCellCount); DDX_Text(pDX, IDEDT_STATS_CNTR_BNDB, m_ConBBounds); DDX_Text(pDX, IDEDT_STATS_CNTR_BNDL, m_ConLBounds); DDX_Text(pDX, IDEDT_STATS_CNTR_BNDR, m_ConRBounds); DDX_Text(pDX, IDEDT_STATS_CNTR_BNDT, m_ConTBounds); DDX_Text(pDX, IDEDT_STATS_COLPOS, m_uColPosition); DDX_Text(pDX, IDEDT_STATS_ROWPOS, m_uRowPosition); DDX_Text(pDX, IDEDT_STATS_CELL_BNDB, m_uCellBBounds); DDX_Text(pDX, IDEDT_STATS_CELL_BNDL, m_uCellLBounds); DDX_Text(pDX, IDEDT_STATS_CELL_BNDR, m_uCellRBounds); DDX_Text(pDX, IDEDT_STATS_CELL_BNDT, m_uCellTBounds); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CStatisticsDlg, CDialog) //{{AFX_MSG_MAP(CStatisticsDlg) ON_CBN_SELCHANGE(IDCMB_STATS_INDEX, OnSelChangeStatsIndex) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CStatisticsDlg message handlers BOOL CStatisticsDlg::OnInitDialog() { CDialog::OnInitDialog(); L_INT nRet; RECT rcRect; L_UINT uRow, uCol; CString strText; L_INT nI; L_INT nIndex; m_pImageViewer->GetActionCount(&m_uActionCounts, 0); m_uCellCount = m_pImageViewer->GetCellCount(0); for (nIndex = 0; nIndex < m_uCellCount; nIndex++) { if(m_pImageViewer) { if (m_pImageViewer->IsCellSelected(nIndex,0)) break; } } if (nIndex == m_uCellCount) nIndex = -1; nRet = m_pImageViewer->GetCellBounds(max(0, nIndex), &rcRect, 0); if (nRet == SUCCESS) { m_uCellLBounds = (float)rcRect.left; m_uCellTBounds = (float)rcRect.top; m_uCellRBounds = (float)rcRect.right; m_uCellBBounds = (float)rcRect.bottom; } nRet = m_pImageViewer->GetCellPosition(max(0, nIndex), &uRow, &uCol, 0); if (nRet == SUCCESS) { m_uColPosition = uRow; m_uRowPosition = uCol; } m_pImageViewer->GetBounds(&rcRect, 0); m_ConLBounds = rcRect.left; m_ConTBounds = rcRect.top; m_ConRBounds = rcRect.right; m_ConBBounds = rcRect.bottom; for (nI = 0; nI < m_uCellCount; nI++) { strText.Format(TEXT("%d"), nI); m_cmbComIndex.AddString(strText); } m_cmbComIndex.SetCurSel(max(0, nIndex)); if (m_uCellCount == 0) m_cmbComIndex.EnableWindow(FALSE); else { m_strFreeze = m_pImageViewer->IsCellFrozen(max(0, nIndex), 0) ? TEXT("Yes") : TEXT("No"); m_strCellSelect = m_pImageViewer->IsCellSelected(max(0, nIndex), 0) ? TEXT("Yes") : TEXT("No"); } UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CStatisticsDlg::OnSelChangeStatsIndex() { L_INT nRet; L_INT nIndex = m_cmbComIndex.GetCurSel(); RECT rcRect; L_UINT uRow, uCol; nRet = m_pImageViewer->GetCellBounds(nIndex, &rcRect, 0); if (nRet == SUCCESS) { m_uCellLBounds = (float)rcRect.left; m_uCellTBounds = (float)rcRect.top; m_uCellRBounds = (float)rcRect.right; m_uCellBBounds = (float)rcRect.bottom; } nRet = m_pImageViewer->GetCellPosition(nIndex, &uRow, &uCol, 0); if (nRet == SUCCESS) { m_uColPosition = uRow; m_uRowPosition = uCol; } m_strFreeze = m_pImageViewer->IsCellFrozen(nIndex, 0) ? TEXT("Yes") : TEXT("No"); m_strCellSelect = m_pImageViewer->IsCellSelected(nIndex, 0) ? TEXT("Yes") : TEXT("No"); UpdateData(FALSE); }