void CBaseView::OnMouseMove(UINT nFlags, CPoint point) { CWnd::OnMouseMove(nFlags, point); CStatusBar* pStatusBar = DYNAMIC_DOWNCAST(CStatusBar, AfxGetMainWnd()->GetDlgItem(AFX_IDW_STATUS_BAR)); ASSERT(pStatusBar != NULL); Point2d pnt((float)point.x, (float)point.y); pnt *= m_graph->xf.displayToModel(); CString str; int index = pStatusBar->CommandToIndex(ID_INDICATOR_X); if (index >= 0) { str.Format(_T("X: %.2lf"), pnt.x); pStatusBar->SetPaneText(index, str); } index = pStatusBar->CommandToIndex(ID_INDICATOR_Y); if (index >= 0) { str.Format(_T("Y: %.2lf"), pnt.y); pStatusBar->SetPaneText(index, str); } }
BOOL CCOXRayDoc::OnOpenDocument(LPCTSTR lpszPathName) { if (!CDocument::OnOpenDocument(lpszPathName)) return FALSE; // TODO: 在此添加您专用的创建代码 USES_CONVERSION; char *filename = W2A(lpszPathName); if (m_pHWorkImage == NULL) { m_pHWorkImage = new HImage(); } if (m_pOriginImage == NULL) { m_pOriginImage = new HImage(); } // 清空Undo ClearUndoDraw(); ClearUndoImage(); m_UndoType.RemoveAll(); m_Stopwatch.Start(); HImage Image; try { *m_pHWorkImage = HImage::ReadImage(filename); } catch (HException &except) { CString strErrorMsg; strErrorMsg.Format(_T("读图像失败,请确认是否为图像格式!")); AfxMessageBox(strErrorMsg); return FALSE; } m_Stopwatch.Stop(); // 转换为8位3通道 // if (GetImageBits(*m_pHWorkImage) == 16) // { // *m_pHWorkImage = ConvertImage(*m_pHWorkImage,IPL_DEPTH_8U,3); // } // 备份原始图像 *m_pOriginImage = *m_pHWorkImage; m_dbZoomFactor = 1; m_nChanels = m_pHWorkImage->CountChannels(); // 转换为灰度图像 // if (m_nChanels > 1) // { // *m_pHWorkImage = m_pHWorkImage->Rgb1ToGray(); // m_nChanels = 1; // } CString strTime,strInfo,strExt,strZoom; strExt = CUtils::GetFileExt(lpszPathName); strExt.MakeUpper(); int bits = GetImageBits(m_pHWorkImage->GetImageType()[0].S()); bits *= m_nChanels; strTime.Format(_T("Time: %.2f s"),m_Stopwatch.GetSecond()); strInfo.Format(_T("%s %dx%dx%d"),strExt,m_pHWorkImage->Width(),m_pHWorkImage->Height(),bits); strZoom.Format(_T("%.0f%%"),m_dbZoomFactor * 100); CStatusBar *pStatusBar = ((CMainFrame *)AfxGetMainWnd())->GetStatusBar(); int nIndex = pStatusBar->CommandToIndex(ID_INDICATOR_TIME); pStatusBar->SetPaneText(nIndex,strTime); nIndex = pStatusBar->CommandToIndex(ID_INDICATOR_IMG_INFO); pStatusBar->SetPaneText(nIndex,strInfo); nIndex = pStatusBar->CommandToIndex(ID_INDICATOR_ZOOM); pStatusBar->SetPaneText(nIndex,strZoom); //UpdateAllViews(NULL,WM_USER_NEWIMAGE); OnBtnFitWindow(); return TRUE; }