CompareDlg.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. /**************************************************************************************************
  2. 版本所有(C), 2020-2022, 北京普达迪泰
  3. ***************************************************************************************************
  4. 文 件 名: CompareDlg.cpp
  5. 功能描述: 结果比对
  6. 版 本 号: 1.00初版
  7. 作 者: HYF
  8. 生成日期; 2021-12-20
  9. 最近修改:
  10. 函数列表:
  11. 修改历史:
  12. 1.日 期 :2021-12-20
  13. 作 者 : HYF
  14. 修改内容 : 创建文件
  15. **************************************************************************************************/
  16. #include "pch.h"
  17. #include "DMS.h"
  18. #include "CompareDlg.h"
  19. #include "afxdialogex.h"
  20. #include "DmsDoc.h"
  21. #include "LABEL.H"
  22. #include "DmsDoc.h"
  23. #include "CppSQLite3.h"
  24. #include "TaskManager.h"
  25. #include "PostureDataAngle.h"
  26. #include "PostureDataPoint.h"
  27. #include "GridCtrl.h"
  28. #include "IDPMSManager.h"
  29. #include "DynamicData.h"
  30. IMPLEMENT_DYNAMIC(CompareDlg, CDialogEx)
  31. CompareDlg::CompareDlg(CWnd* pParent /*=nullptr*/)
  32. : CDialogEx(IDD_DLG_DYNAMIC_COMPARE, pParent)
  33. {
  34. }
  35. CompareDlg::CompareDlg(CWnd* pParent, DWORD taskId)
  36. : CDialogEx(IDD_DLG_DYNAMIC_COMPARE, pParent)
  37. ,m_taskId(taskId)
  38. {
  39. }
  40. CompareDlg::~CompareDlg()
  41. {
  42. }
  43. void CompareDlg::DoDataExchange(CDataExchange* pDX)
  44. {
  45. CDialogEx::DoDataExchange(pDX);
  46. DDX_Control(pDX, IDC_CUSTOM_GRIDCTRL, m_GridCtrl);
  47. }
  48. BEGIN_MESSAGE_MAP(CompareDlg, CDialogEx)
  49. END_MESSAGE_MAP()
  50. // 消息处理程序
  51. /**************************************************************************************************
  52. 函 数 名 :GetDocument
  53. 功能描述 :获取文档对象
  54. 输入参数 :无
  55. 输出参数 :无
  56. 返 回 值 :void
  57. **************************************************************************************************/
  58. CDmsDoc *CompareDlg::GetDocument()
  59. {
  60. CFrameWnd *pFrm = (CFrameWnd *)(AfxGetApp()->m_pMainWnd);
  61. ASSERT(pFrm);
  62. CView *pView = pFrm->GetActiveView();
  63. CDmsDoc *pDoc = (CDmsDoc *)(pView->GetDocument());
  64. ASSERT(pDoc->IsKindOf(RUNTIME_CLASS(CDmsDoc)));
  65. return pDoc;
  66. }
  67. /**************************************************************************************************
  68. 函 数 名 :OnInitDialog
  69. 功能描述 :初始化UI数据展示
  70. 输入参数 :无
  71. 输出参数 :无
  72. 返 回 值 :void
  73. **************************************************************************************************/
  74. BOOL CompareDlg::OnInitDialog()
  75. {
  76. CDialogEx::OnInitDialog();
  77. //创建图标
  78. HICON icon;
  79. //加载图标
  80. icon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  81. SetIcon(icon, true);
  82. SetIcon(icon, false);
  83. // 初始化Grid数据
  84. InitGridCompareData();
  85. return TRUE;
  86. }
  87. /**************************************************************************************************
  88. 函 数 名 :InitGridReportData
  89. 功能描述 :展示点云数据
  90. 输入参数 :略
  91. 输出参数 :略
  92. 返 回 值 :略
  93. **************************************************************************************************/
  94. void CompareDlg::InitGridCompareData()
  95. {
  96. m_GridCtrl.DeleteAllItems();
  97. m_GridCtrl.SetGridLines(GVL_NONE);
  98. m_GridCtrl.SetEditable(FALSE);
  99. m_GridCtrl.GetDefaultCell(FALSE, FALSE)->SetBackClr(RGB(0xFF, 0xFF, 0xFF));
  100. m_GridCtrl.SetSingleRowSelection(FALSE);
  101. m_GridCtrl.SetSingleColSelection(FALSE);
  102. m_GridCtrl.EnableSelection(FALSE);
  103. m_GridCtrl.SetFrameFocusCell(FALSE);
  104. TRY
  105. {
  106. m_GridCtrl.SetRowCount(50);
  107. m_GridCtrl.SetColumnCount(10);
  108. m_GridCtrl.SetFixedRowCount(0);
  109. m_GridCtrl.SetFixedColumnCount(0);
  110. m_GridCtrl.SetGridBkColor(RGB(255, 255, 255));
  111. }
  112. CATCH(CMemoryException, e)
  113. {
  114. e->ReportError();
  115. return;
  116. }
  117. END_CATCH
  118. CRect rect;
  119. m_GridCtrl.GetClientRect(&rect);
  120. int width = rect.Width() / 10;
  121. for (int icol = 0; icol < 10; icol++)
  122. {
  123. m_GridCtrl.SetColumnWidth(icol, width);
  124. }
  125. // Get the font
  126. CFont* pFont = m_GridCtrl.GetFont();
  127. int iRow = 0;
  128. COLORREF bkClrHeader = RGB(128, 128, 128);
  129. COLORREF bkClrData = RGB(255, 255, 255);
  130. iRow = PrintPointData(m_taskId, iRow);
  131. }
  132. /**************************************************************************************************
  133. 函 数 名 :PrintPointData
  134. 功能描述 :显示数据-点
  135. 输出参数 :略
  136. 返 回 值 :略
  137. **************************************************************************************************/
  138. int CompareDlg::PrintPointData(DWORD dwTaskId, int iStartRow)
  139. {
  140. // 数据访问入口
  141. IDPMSManager *pManager = IDPMSManager::GetManager();
  142. DynamicData *pData = pManager->m_pDynamicData;
  143. if (pData == NULL) return 0;
  144. POSITION pos;
  145. CPosturePointList *pPointList = pData->GetPointList();
  146. int iCount = (int)pPointList->GetCount();
  147. if (iCount <= 0) return 0;
  148. // Get the font
  149. CFont* pFont = m_GridCtrl.GetFont();
  150. CString str;
  151. int iRow = iStartRow;
  152. int iCol = 0;
  153. GV_ITEM ItemCat;
  154. ItemCat.row = iRow;
  155. ItemCat.col = iCol;
  156. ItemCat.mask = (GVIF_TEXT | GVIF_BORDER | GVIF_FONT | GVIF_FORMAT);
  157. ItemCat.nFormat = DT_SINGLELINE | DT_VCENTER | DT_LEFT;
  158. ItemCat.nBorder = GVIS_BDR_BOTTOM;
  159. ItemCat.strText = _T("结果比对:点");
  160. LOGFONT lfTitle;
  161. pFont->GetLogFont(&lfTitle);
  162. // Make it true-type
  163. memcpy(lfTitle.lfFaceName, _T("Arial"), 6);
  164. lfTitle.lfWeight = FW_BOLD;
  165. memcpy(&(ItemCat.lfFont), &lfTitle, sizeof(LOGFONT));
  166. //Item.lfFont = lf;
  167. m_GridCtrl.SetItem(&ItemCat);
  168. m_GridCtrl.MergeCells(iRow, iCol, iRow, 9);
  169. /*******************************************************************************************/
  170. iRow += 1;
  171. GV_ITEM ItemTitle;
  172. ItemTitle.mask = GVIF_TEXT | GVIF_FORMAT | GVIF_BORDER;
  173. ItemTitle.nBorder = GVIS_BDR_BOTTOM;
  174. ItemTitle.nFormat = DT_SINGLELINE | DT_VCENTER;
  175. ItemTitle.row = iRow;
  176. ItemTitle.col = iCol;
  177. ItemTitle.nFormat = DT_CENTER;
  178. ItemTitle.strText = _T("序号");
  179. m_GridCtrl.SetItem(&ItemTitle);
  180. m_GridCtrl.MergeCells(iRow, iCol, iRow + 1, iCol);
  181. ItemTitle.row = iRow;
  182. ItemTitle.col = iCol + 1;
  183. ItemTitle.nFormat = DT_CENTER;
  184. ItemTitle.strText = _T("名称");
  185. m_GridCtrl.SetItem(&ItemTitle);
  186. m_GridCtrl.MergeCells(iRow, iCol + 1, iRow + 1, iCol + 1);
  187. ItemTitle.row = iRow;
  188. ItemTitle.col = iCol + 2;
  189. ItemTitle.nFormat = DT_CENTER;
  190. ItemTitle.strText = _T("编码");
  191. m_GridCtrl.SetItem(&ItemTitle);
  192. m_GridCtrl.MergeCells(iRow, iCol + 2, iRow + 1, iCol + 2);
  193. ItemTitle.row = iRow;
  194. ItemTitle.col = iCol + 3;
  195. ItemTitle.nFormat = DT_CENTER;
  196. ItemTitle.strText = _T("理论值");
  197. m_GridCtrl.SetItem(&ItemTitle);
  198. m_GridCtrl.MergeCells(iRow, iCol + 3, iRow, iCol + 5);
  199. ItemTitle.row = iRow + 1;
  200. ItemTitle.col = iCol + 3;
  201. ItemTitle.nFormat = DT_CENTER;
  202. ItemTitle.strText = _T("X");
  203. m_GridCtrl.SetItem(&ItemTitle);
  204. ItemTitle.row = iRow + 1;
  205. ItemTitle.col = iCol + 4;
  206. ItemTitle.nFormat = DT_CENTER;
  207. ItemTitle.strText = _T("Y");
  208. m_GridCtrl.SetItem(&ItemTitle);
  209. ItemTitle.row = iRow + 1;
  210. ItemTitle.col = iCol + 5;
  211. ItemTitle.nFormat = DT_CENTER;
  212. ItemTitle.strText = _T("Z");
  213. m_GridCtrl.SetItem(&ItemTitle);
  214. ItemTitle.row = iRow;
  215. ItemTitle.col = iCol + 6;
  216. ItemTitle.nFormat = DT_CENTER;
  217. ItemTitle.strText = _T("实测值");
  218. m_GridCtrl.SetItem(&ItemTitle);
  219. m_GridCtrl.MergeCells(iRow, iCol + 6, iRow, iCol + 8);
  220. ItemTitle.row = iRow + 1;
  221. ItemTitle.col = iCol + 6;
  222. ItemTitle.nFormat = DT_CENTER;
  223. ItemTitle.strText = _T("X");
  224. m_GridCtrl.SetItem(&ItemTitle);
  225. ItemTitle.row = iRow + 1;
  226. ItemTitle.col = iCol + 7;
  227. ItemTitle.nFormat = DT_CENTER;
  228. ItemTitle.strText = _T("Y");
  229. m_GridCtrl.SetItem(&ItemTitle);
  230. ItemTitle.row = iRow + 1;
  231. ItemTitle.col = iCol + 8;
  232. ItemTitle.nFormat = DT_CENTER;
  233. ItemTitle.strText = _T("Z");
  234. m_GridCtrl.SetItem(&ItemTitle);
  235. ItemTitle.row = iRow;
  236. ItemTitle.col = iCol + 9;
  237. ItemTitle.nFormat = DT_CENTER;
  238. ItemTitle.strText = _T("说明");
  239. m_GridCtrl.SetItem(&ItemTitle);
  240. m_GridCtrl.MergeCells(iRow, iCol + 9, iRow + 1, iCol + 9);
  241. GV_ITEM Item;
  242. Item.mask = GVIF_TEXT | GVIF_FORMAT;
  243. Item.nFormat = DT_SINGLELINE | DT_VCENTER;
  244. iRow += 1;
  245. int iIndex = 0;
  246. PostureDataPoint *pPoint = NULL;
  247. pos = pPointList->GetHeadPosition();
  248. while (pos != NULL)
  249. {
  250. pPoint = (PostureDataPoint *)pPointList->GetNext(pos);
  251. if (pPoint != NULL)
  252. {
  253. iRow += 1;
  254. iIndex++;
  255. // 序号
  256. Item.row = iRow;
  257. Item.col = iCol;
  258. Item.nFormat = DT_CENTER;
  259. str.Format("%d", iIndex);
  260. Item.strText = str;
  261. m_GridCtrl.SetItem(&Item);
  262. // 名称
  263. Item.row = iRow;
  264. Item.col = iCol + 1;
  265. Item.nFormat = DT_CENTER;
  266. str.Format("%s", pPoint->GetPointTitle());
  267. Item.strText = str;
  268. m_GridCtrl.SetItem(&Item);
  269. // CODE
  270. Item.row = iRow;
  271. Item.col = iCol + 2;
  272. Item.nFormat = DT_CENTER;
  273. str.Format("%s", pPoint->GetPointCode());
  274. Item.strText = str;
  275. m_GridCtrl.SetItem(&Item);
  276. // 理论 - X
  277. Item.row = iRow;
  278. Item.col = iCol + 3;
  279. Item.nFormat = DT_RIGHT;
  280. str.Format("%.3f", pPoint->GetPointEX());
  281. Item.strText = str;
  282. m_GridCtrl.SetItem(&Item);
  283. // 理论 - Y
  284. Item.row = iRow;
  285. Item.col = iCol + 4;
  286. Item.nFormat = DT_RIGHT;
  287. str.Format("%.3f", pPoint->GetPointEY());
  288. Item.strText = str;
  289. m_GridCtrl.SetItem(&Item);
  290. // 理论 - Z
  291. Item.row = iRow;
  292. Item.col = iCol + 5;
  293. Item.nFormat = DT_RIGHT;
  294. str.Format("%.3f", pPoint->GetPointEZ());
  295. Item.strText = str;
  296. m_GridCtrl.SetItem(&Item);
  297. // 实测 - X
  298. Item.row = iRow;
  299. Item.col = iCol + 6;
  300. Item.nFormat = DT_RIGHT;
  301. str.Format("%.3f", pPoint->GetPointAX());
  302. Item.strText = str;
  303. m_GridCtrl.SetItem(&Item);
  304. // 实测 - Y
  305. Item.row = iRow;
  306. Item.col = iCol + 7;
  307. Item.nFormat = DT_RIGHT;
  308. str.Format("%.3f", pPoint->GetPointAY());
  309. Item.strText = str;
  310. m_GridCtrl.SetItem(&Item);
  311. // 实测 - Z
  312. Item.row = iRow;
  313. Item.col = iCol + 8;
  314. Item.nFormat = DT_RIGHT;
  315. str.Format("%.3f", pPoint->GetPointAZ());
  316. Item.strText = str;
  317. m_GridCtrl.SetItem(&Item);
  318. // 说明
  319. Item.row = iRow;
  320. Item.col = iCol + 9;
  321. Item.nFormat = DT_LEFT;
  322. str.Format("%s", pPoint->GetPointDesc());
  323. Item.strText = str;
  324. m_GridCtrl.SetItem(&Item);
  325. }
  326. }
  327. return iRow + 1;
  328. }