/************************************************************************************************** 版本所有(C), 2020-2022, 北京普达迪泰 *************************************************************************************************** 文 件 名: CompareDlg.cpp 功能描述: 结果比对 版 本 号: 1.00初版 作 者: HYF 生成日期; 2021-12-20 最近修改: 函数列表: 修改历史: 1.日 期 :2021-12-20 作 者 : HYF 修改内容 : 创建文件 **************************************************************************************************/ #include "pch.h" #include "DMS.h" #include "CompareDlg.h" #include "afxdialogex.h" #include "DmsDoc.h" #include "LABEL.H" #include "DmsDoc.h" #include "CppSQLite3.h" #include "TaskManager.h" #include "PostureDataAngle.h" #include "PostureDataPoint.h" #include "GridCtrl.h" #include "IDPMSManager.h" #include "DynamicData.h" IMPLEMENT_DYNAMIC(CompareDlg, CDialogEx) CompareDlg::CompareDlg(CWnd* pParent /*=nullptr*/) : CDialogEx(IDD_DLG_DYNAMIC_COMPARE, pParent) { } CompareDlg::CompareDlg(CWnd* pParent, DWORD taskId) : CDialogEx(IDD_DLG_DYNAMIC_COMPARE, pParent) ,m_taskId(taskId) { } CompareDlg::~CompareDlg() { } void CompareDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Control(pDX, IDC_CUSTOM_GRIDCTRL, m_GridCtrl); } BEGIN_MESSAGE_MAP(CompareDlg, CDialogEx) END_MESSAGE_MAP() // 消息处理程序 /************************************************************************************************** 函 数 名 :GetDocument 功能描述 :获取文档对象 输入参数 :无 输出参数 :无 返 回 值 :void **************************************************************************************************/ CDmsDoc *CompareDlg::GetDocument() { CFrameWnd *pFrm = (CFrameWnd *)(AfxGetApp()->m_pMainWnd); ASSERT(pFrm); CView *pView = pFrm->GetActiveView(); CDmsDoc *pDoc = (CDmsDoc *)(pView->GetDocument()); ASSERT(pDoc->IsKindOf(RUNTIME_CLASS(CDmsDoc))); return pDoc; } /************************************************************************************************** 函 数 名 :OnInitDialog 功能描述 :初始化UI数据展示 输入参数 :无 输出参数 :无 返 回 值 :void **************************************************************************************************/ BOOL CompareDlg::OnInitDialog() { CDialogEx::OnInitDialog(); //创建图标 HICON icon; //加载图标 icon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); SetIcon(icon, true); SetIcon(icon, false); // 初始化Grid数据 InitGridCompareData(); return TRUE; } /************************************************************************************************** 函 数 名 :InitGridReportData 功能描述 :展示点云数据 输入参数 :略 输出参数 :略 返 回 值 :略 **************************************************************************************************/ void CompareDlg::InitGridCompareData() { m_GridCtrl.DeleteAllItems(); m_GridCtrl.SetGridLines(GVL_NONE); m_GridCtrl.SetEditable(FALSE); m_GridCtrl.GetDefaultCell(FALSE, FALSE)->SetBackClr(RGB(0xFF, 0xFF, 0xFF)); m_GridCtrl.SetSingleRowSelection(FALSE); m_GridCtrl.SetSingleColSelection(FALSE); m_GridCtrl.EnableSelection(FALSE); m_GridCtrl.SetFrameFocusCell(FALSE); TRY { m_GridCtrl.SetRowCount(50); m_GridCtrl.SetColumnCount(10); m_GridCtrl.SetFixedRowCount(0); m_GridCtrl.SetFixedColumnCount(0); m_GridCtrl.SetGridBkColor(RGB(255, 255, 255)); } CATCH(CMemoryException, e) { e->ReportError(); return; } END_CATCH CRect rect; m_GridCtrl.GetClientRect(&rect); int width = rect.Width() / 10; for (int icol = 0; icol < 10; icol++) { m_GridCtrl.SetColumnWidth(icol, width); } // Get the font CFont* pFont = m_GridCtrl.GetFont(); int iRow = 0; COLORREF bkClrHeader = RGB(128, 128, 128); COLORREF bkClrData = RGB(255, 255, 255); iRow = PrintPointData(m_taskId, iRow); } /************************************************************************************************** 函 数 名 :PrintPointData 功能描述 :显示数据-点 输出参数 :略 返 回 值 :略 **************************************************************************************************/ int CompareDlg::PrintPointData(DWORD dwTaskId, int iStartRow) { // 数据访问入口 IDPMSManager *pManager = IDPMSManager::GetManager(); DynamicData *pData = pManager->m_pDynamicData; if (pData == NULL) return 0; POSITION pos; CPosturePointList *pPointList = pData->GetPointList(); int iCount = (int)pPointList->GetCount(); if (iCount <= 0) return 0; // Get the font CFont* pFont = m_GridCtrl.GetFont(); CString str; int iRow = iStartRow; int iCol = 0; GV_ITEM ItemCat; ItemCat.row = iRow; ItemCat.col = iCol; ItemCat.mask = (GVIF_TEXT | GVIF_BORDER | GVIF_FONT | GVIF_FORMAT); ItemCat.nFormat = DT_SINGLELINE | DT_VCENTER | DT_LEFT; ItemCat.nBorder = GVIS_BDR_BOTTOM; ItemCat.strText = _T("结果比对:点"); LOGFONT lfTitle; pFont->GetLogFont(&lfTitle); // Make it true-type memcpy(lfTitle.lfFaceName, _T("Arial"), 6); lfTitle.lfWeight = FW_BOLD; memcpy(&(ItemCat.lfFont), &lfTitle, sizeof(LOGFONT)); //Item.lfFont = lf; m_GridCtrl.SetItem(&ItemCat); m_GridCtrl.MergeCells(iRow, iCol, iRow, 9); /*******************************************************************************************/ iRow += 1; GV_ITEM ItemTitle; ItemTitle.mask = GVIF_TEXT | GVIF_FORMAT | GVIF_BORDER; ItemTitle.nBorder = GVIS_BDR_BOTTOM; ItemTitle.nFormat = DT_SINGLELINE | DT_VCENTER; ItemTitle.row = iRow; ItemTitle.col = iCol; ItemTitle.nFormat = DT_CENTER; ItemTitle.strText = _T("序号"); m_GridCtrl.SetItem(&ItemTitle); m_GridCtrl.MergeCells(iRow, iCol, iRow + 1, iCol); ItemTitle.row = iRow; ItemTitle.col = iCol + 1; ItemTitle.nFormat = DT_CENTER; ItemTitle.strText = _T("名称"); m_GridCtrl.SetItem(&ItemTitle); m_GridCtrl.MergeCells(iRow, iCol + 1, iRow + 1, iCol + 1); ItemTitle.row = iRow; ItemTitle.col = iCol + 2; ItemTitle.nFormat = DT_CENTER; ItemTitle.strText = _T("编码"); m_GridCtrl.SetItem(&ItemTitle); m_GridCtrl.MergeCells(iRow, iCol + 2, iRow + 1, iCol + 2); ItemTitle.row = iRow; ItemTitle.col = iCol + 3; ItemTitle.nFormat = DT_CENTER; ItemTitle.strText = _T("理论值"); m_GridCtrl.SetItem(&ItemTitle); m_GridCtrl.MergeCells(iRow, iCol + 3, iRow, iCol + 5); ItemTitle.row = iRow + 1; ItemTitle.col = iCol + 3; ItemTitle.nFormat = DT_CENTER; ItemTitle.strText = _T("X"); m_GridCtrl.SetItem(&ItemTitle); ItemTitle.row = iRow + 1; ItemTitle.col = iCol + 4; ItemTitle.nFormat = DT_CENTER; ItemTitle.strText = _T("Y"); m_GridCtrl.SetItem(&ItemTitle); ItemTitle.row = iRow + 1; ItemTitle.col = iCol + 5; ItemTitle.nFormat = DT_CENTER; ItemTitle.strText = _T("Z"); m_GridCtrl.SetItem(&ItemTitle); ItemTitle.row = iRow; ItemTitle.col = iCol + 6; ItemTitle.nFormat = DT_CENTER; ItemTitle.strText = _T("实测值"); m_GridCtrl.SetItem(&ItemTitle); m_GridCtrl.MergeCells(iRow, iCol + 6, iRow, iCol + 8); ItemTitle.row = iRow + 1; ItemTitle.col = iCol + 6; ItemTitle.nFormat = DT_CENTER; ItemTitle.strText = _T("X"); m_GridCtrl.SetItem(&ItemTitle); ItemTitle.row = iRow + 1; ItemTitle.col = iCol + 7; ItemTitle.nFormat = DT_CENTER; ItemTitle.strText = _T("Y"); m_GridCtrl.SetItem(&ItemTitle); ItemTitle.row = iRow + 1; ItemTitle.col = iCol + 8; ItemTitle.nFormat = DT_CENTER; ItemTitle.strText = _T("Z"); m_GridCtrl.SetItem(&ItemTitle); ItemTitle.row = iRow; ItemTitle.col = iCol + 9; ItemTitle.nFormat = DT_CENTER; ItemTitle.strText = _T("说明"); m_GridCtrl.SetItem(&ItemTitle); m_GridCtrl.MergeCells(iRow, iCol + 9, iRow + 1, iCol + 9); GV_ITEM Item; Item.mask = GVIF_TEXT | GVIF_FORMAT; Item.nFormat = DT_SINGLELINE | DT_VCENTER; iRow += 1; int iIndex = 0; PostureDataPoint *pPoint = NULL; pos = pPointList->GetHeadPosition(); while (pos != NULL) { pPoint = (PostureDataPoint *)pPointList->GetNext(pos); if (pPoint != NULL) { iRow += 1; iIndex++; // 序号 Item.row = iRow; Item.col = iCol; Item.nFormat = DT_CENTER; str.Format("%d", iIndex); Item.strText = str; m_GridCtrl.SetItem(&Item); // 名称 Item.row = iRow; Item.col = iCol + 1; Item.nFormat = DT_CENTER; str.Format("%s", pPoint->GetPointTitle()); Item.strText = str; m_GridCtrl.SetItem(&Item); // CODE Item.row = iRow; Item.col = iCol + 2; Item.nFormat = DT_CENTER; str.Format("%s", pPoint->GetPointCode()); Item.strText = str; m_GridCtrl.SetItem(&Item); // 理论 - X Item.row = iRow; Item.col = iCol + 3; Item.nFormat = DT_RIGHT; str.Format("%.3f", pPoint->GetPointEX()); Item.strText = str; m_GridCtrl.SetItem(&Item); // 理论 - Y Item.row = iRow; Item.col = iCol + 4; Item.nFormat = DT_RIGHT; str.Format("%.3f", pPoint->GetPointEY()); Item.strText = str; m_GridCtrl.SetItem(&Item); // 理论 - Z Item.row = iRow; Item.col = iCol + 5; Item.nFormat = DT_RIGHT; str.Format("%.3f", pPoint->GetPointEZ()); Item.strText = str; m_GridCtrl.SetItem(&Item); // 实测 - X Item.row = iRow; Item.col = iCol + 6; Item.nFormat = DT_RIGHT; str.Format("%.3f", pPoint->GetPointAX()); Item.strText = str; m_GridCtrl.SetItem(&Item); // 实测 - Y Item.row = iRow; Item.col = iCol + 7; Item.nFormat = DT_RIGHT; str.Format("%.3f", pPoint->GetPointAY()); Item.strText = str; m_GridCtrl.SetItem(&Item); // 实测 - Z Item.row = iRow; Item.col = iCol + 8; Item.nFormat = DT_RIGHT; str.Format("%.3f", pPoint->GetPointAZ()); Item.strText = str; m_GridCtrl.SetItem(&Item); // 说明 Item.row = iRow; Item.col = iCol + 9; Item.nFormat = DT_LEFT; str.Format("%s", pPoint->GetPointDesc()); Item.strText = str; m_GridCtrl.SetItem(&Item); } } return iRow + 1; }