StaticTask.cpp 80 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876
  1. /**************************************************************************************************
  2. 版本所有(C), 2020-2022, 北京普达迪泰
  3. ***************************************************************************************************
  4. 文 件 名: StaticTask.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 "StaticTask.h"
  19. #include "DmsDoc.h"
  20. #include "TaskManager.h"
  21. #include "EquipDataManager.h"
  22. #include "EquipDataCircleManager.h"
  23. #include "EquipDataPlaneManager.h"
  24. #include "EquipDataLineManager.h"
  25. #include "EquipDataPointManager.h"
  26. #include "EquipDataCylinderManager.h"
  27. #include "CppSQLite3.h"
  28. #include "EnvelopeDlg.h"
  29. #include "GuideDlg.h"
  30. #include "StaticReport.h"
  31. #include "GridCtrl.h"
  32. #include "OSGView.h"
  33. #include "CameraConfigDlg.h"
  34. #include "MainFrm.h"
  35. #include "IDPMSManager.h"
  36. #include "StaticData.h"
  37. #include "IPNDlg.h"
  38. #include "DlgTest.h"
  39. #include "CameraInfo.h"
  40. // 定时器
  41. #define MEASURE_TIMER 1000
  42. // CStaticTask
  43. IMPLEMENT_DYNCREATE(CStaticTask, CFormView)
  44. CStaticTask::CStaticTask()
  45. : CFormView(IDD_VIEW_STATIC_TASK)
  46. , m_bIsAttached(FALSE)
  47. {
  48. m_BkBrush.CreateSolidBrush(RGB(247, 247, 247));
  49. m_pCamMenu = NULL;
  50. }
  51. CStaticTask::~CStaticTask()
  52. {
  53. if (m_pCamMenu != NULL)
  54. {
  55. delete m_pCamMenu;
  56. m_pCamMenu = NULL;
  57. }
  58. }
  59. void CStaticTask::DoDataExchange(CDataExchange* pDX)
  60. {
  61. CFormView::DoDataExchange(pDX);
  62. DDX_Control(pDX, IDC_STATIC_TASK_TITLE, m_Static_Title);
  63. DDX_Control(pDX, IDC_STATIC_POINT_TITLE, m_Static_PointTitle);
  64. DDX_Control(pDX, IDC_TREE_DATA, m_TreeCtrl);
  65. DDX_Control(pDX, IDC_GRIDCTRL_POINT, m_GridCtrl);
  66. DDX_Control(pDX, IDC_COMBO_CS, m_Combo_CS);
  67. DDX_Control(pDX, IDC_BTN_REPORT, m_Btn_Report);
  68. DDX_Control(pDX, IDC_BTN_COMPARE, m_Btn_Compare);
  69. DDX_Control(pDX, IDC_STATIC_EQUIP_TYPE_CODE, m_Static_EquipTypeCode);
  70. DDX_Control(pDX, IDC_STATIC_EQUIP_CODE, m_Static_EquipCode);
  71. DDX_Control(pDX, IDC_MBTN_STATIC_CAMERA, m_MBtn_Cam);
  72. DDX_Control(pDX, IDC_BTN_AUTO, m_Btn_Auto);
  73. DDX_Control(pDX, IDC_BTN_UPDATE, m_Btn_Update);
  74. }
  75. BEGIN_MESSAGE_MAP(CStaticTask, CFormView)
  76. ON_BN_CLICKED(IDC_BTN_CAMERA, &CStaticTask::OnBnClickedBtnCamera)
  77. ON_WM_CREATE()
  78. ON_NOTIFY(TVN_SELCHANGED, IDC_TREE_DATA, &CStaticTask::OnTvnSelchangedTreeData)
  79. ON_NOTIFY(TVN_BEGINLABELEDIT, IDC_TREE_DATA, &CStaticTask::OnTvnBeginlabeleditTreeData)
  80. ON_NOTIFY(TVN_ENDLABELEDIT, IDC_TREE_DATA, &CStaticTask::OnTvnEndlabeleditTreeData)
  81. ON_BN_CLICKED(IDC_BTN_AUTO, &CStaticTask::OnBnClickedBtnAuto)
  82. ON_BN_CLICKED(IDC_BTN_COMPARE, &CStaticTask::OnBnClickedBtnCompare)
  83. ON_BN_CLICKED(IDC_BTN_GUIDE, &CStaticTask::OnBnClickedBtnGuide)
  84. ON_BN_CLICKED(IDC_BTN_REPORT, &CStaticTask::OnBnClickedBtnReport)
  85. ON_WM_DESTROY()
  86. ON_WM_SIZE()
  87. ON_WM_TIMER()
  88. ON_CBN_SELCHANGE(IDC_COMBO_CS, &CStaticTask::OnCbnSelchangeComboCS)
  89. ON_BN_CLICKED(IDC_BTN_FINISH, &CStaticTask::OnBnClickedBtnBack)
  90. ON_BN_CLICKED(IDC_BTN_MESH, &CStaticTask::OnBnClickedBtnIPN)
  91. ON_MESSAGE(WM_SUCCESS , OnMeasureSuccess )
  92. ON_MESSAGE(WM_FAILURE, OnMeasureFailure)
  93. ON_MESSAGE(WM_UPDATE_FAILURE, OnMeasureUpdateFailure)
  94. ON_MESSAGE(WM_UPDATE_SUCCESS, OnMeasureUpdateSuccess)
  95. ON_MESSAGE(WM_CAM_CONFIG_SUCCESS, OnCamConfigSuccess)
  96. ON_MESSAGE(WM_CAM_CONFIG_FAILURE, OnCamConfigFailure)
  97. ON_MESSAGE(WM_START_IDPMS, OnReStartIDPMS)
  98. ON_BN_CLICKED(BTN_AGV, &CStaticTask::OnBnClickedAgv)
  99. ON_BN_CLICKED(IDC_MBTN_STATIC_CAMERA, &CStaticTask::OnBnClickedMbtnStaticCamera)
  100. ON_BN_CLICKED(IDC_BTN_UPDATE, &CStaticTask::OnBnClickedBtnUpdate)
  101. END_MESSAGE_MAP()
  102. // CStaticTask 诊断
  103. #ifdef _DEBUG
  104. void CStaticTask::AssertValid() const
  105. {
  106. CFormView::AssertValid();
  107. }
  108. #ifndef _WIN32_WCE
  109. void CStaticTask::Dump(CDumpContext& dc) const
  110. {
  111. CFormView::Dump(dc);
  112. }
  113. #endif
  114. #endif //_DEBUG
  115. /**************************************************************************************************
  116. 函 数 名 :OnCreate
  117. 功能描述 :消息处理-WM_CREATE
  118. 输入参数 :无
  119. 输出参数 :无
  120. 返 回 值 :void
  121. **************************************************************************************************/
  122. int CStaticTask::OnCreate(LPCREATESTRUCT lpCreateStruct)
  123. {
  124. if (CFormView::OnCreate(lpCreateStruct) == -1)
  125. return -1;
  126. m_pDoc = (CDmsDoc *)GetDocument();
  127. ASSERT(m_pDoc != NULL);
  128. ASSERT(m_pDoc->IsKindOf(RUNTIME_CLASS(CDmsDoc)));
  129. return 0;
  130. }
  131. /**************************************************************************************************
  132. 函 数 名 :OnInitialUpdate
  133. 功能描述 :初始化UI展示
  134. 输入参数 :无
  135. 输出参数 :无
  136. 返 回 值 :void
  137. **************************************************************************************************/
  138. void CStaticTask::OnInitialUpdate()
  139. {
  140. CFormView::OnInitialUpdate();
  141. // 任务标题
  142. m_Static_Title.SetFontSize(16);
  143. m_Static_Title.SetFontBold(TRUE);
  144. // 型号
  145. m_Static_EquipTypeCode.SetFontSize(15);
  146. m_Static_EquipTypeCode.SetFontBold(TRUE);
  147. m_Static_EquipTypeCode.SetTextColor(g_crInfoText);
  148. // 编号
  149. m_Static_EquipCode.SetFontSize(15);
  150. m_Static_EquipCode.SetTextColor(g_crInfoText);
  151. m_Static_EquipCode.SetFontBold(TRUE);
  152. // 从标系
  153. m_Combo_CS.ResetContent();
  154. m_Combo_CS.InsertString(0, _T("空间直角坐标系"));
  155. m_Combo_CS.InsertString(1, _T("球坐标系"));
  156. m_Combo_CS.InsertString(2, _T("柱坐标系"));
  157. m_Combo_CS.SetCurSel(0);
  158. // 相机标定菜单
  159. m_pCamMenu = new CMenu();
  160. m_pCamMenu->LoadMenu(IDM_CAM_STATIC);
  161. m_MBtn_Cam.m_hMenu = m_pCamMenu->GetSubMenu(0)->GetSafeHmenu();
  162. // 设置TreeCtrl风格
  163. DWORD dwStyles = GetWindowLong(m_TreeCtrl.m_hWnd, GWL_STYLE);//获取树控制原风格
  164. dwStyles |= TVS_EDITLABELS | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_SHOWSELALWAYS;
  165. SetWindowLong(m_TreeCtrl.m_hWnd, GWL_STYLE, dwStyles);
  166. HICON hIcon[10];
  167. hIcon[0] = AfxGetApp()->LoadIcon(IDI_POINT_TYPE);
  168. hIcon[1] = AfxGetApp()->LoadIcon(IDI_POINT);
  169. hIcon[2] = AfxGetApp()->LoadIcon(IDI_PLANE_TYPE);
  170. hIcon[3] = AfxGetApp()->LoadIcon(IDI_PLANE);
  171. hIcon[4] = AfxGetApp()->LoadIcon(IDI_CIRCLE_TYPE);
  172. hIcon[5] = AfxGetApp()->LoadIcon(IDI_CIRCLE);
  173. hIcon[6] = AfxGetApp()->LoadIcon(IDI_LINE_TYPE);
  174. hIcon[7] = AfxGetApp()->LoadIcon(IDI_LINE);
  175. hIcon[8] = AfxGetApp()->LoadIcon(IDI_CYLINDER_TYPE);
  176. hIcon[9] = AfxGetApp()->LoadIcon(IDI_CYLINDER);
  177. m_imageList.Create(20, 20, ILC_COLOR32, 4, 4);
  178. m_imageList.SetBkColor(RGB(255, 255, 255));
  179. for (int i = 0; i < 10; i++)
  180. {
  181. m_imageList.Add(hIcon[i]);
  182. }
  183. m_TreeCtrl.SetImageList(&m_imageList, TVSIL_NORMAL);
  184. m_TreeCtrl.SetBkColor(RGB(255, 255, 255));
  185. m_Static_PointTitle.SetWindowText("");
  186. //
  187. m_GridCtrl.SetBkColor(RGB(0xFF, 0xFF, 0xFF));
  188. // 启动定时器
  189. SetTimer(MEASURE_TIMER, 500, NULL);
  190. }
  191. /**************************************************************************************************
  192. 函 数 名 :InitTreeCtrlData
  193. 功能描述 :初始化设备静态测量数据树状展示
  194. 输入参数 :无
  195. 输出参数 :无
  196. 返 回 值 :void
  197. **************************************************************************************************/
  198. void CStaticTask::InitTreeCtrlData()
  199. {
  200. m_TreeCtrl.DeleteAllItems();
  201. // 初始化数据
  202. EquipDataManager *pManager = m_pDoc->GetEquipDataManager();
  203. ASSERT(pManager != NULL);
  204. DWORD dwItemId;
  205. CString szItemTitle;
  206. CString szItemCode;
  207. int iItemType;
  208. CppSQLite3Query q = pManager->Query(m_taskId);
  209. while (!q.eof()) {
  210. dwItemId = q.getIntField("item_id");
  211. iItemType = q.getIntField("item_type");
  212. szItemTitle = q.getStringField("item_title");
  213. szItemCode = q.getStringField("item_code");
  214. switch (iItemType)
  215. {
  216. case 1: // Point
  217. m_hPoints = m_TreeCtrl.InsertItem(_T("Points"), 0, 0);
  218. m_TreeCtrl.SetItemState(m_hPoints, TVIS_BOLD, TVIS_BOLD);
  219. m_TreeCtrl.SetItemData(m_hPoints, 0);
  220. InitTreePointData(dwItemId);
  221. break;
  222. case 2: // Plane
  223. m_hPlanes = m_TreeCtrl.InsertItem(_T("Planes"), 2, 2);
  224. m_TreeCtrl.SetItemState(m_hPlanes, TVIS_BOLD, TVIS_BOLD);
  225. m_TreeCtrl.SetItemData(m_hPlanes, 0);
  226. InitTreePlaneData(dwItemId);
  227. break;
  228. case 3: // Circle
  229. m_hCircles = m_TreeCtrl.InsertItem(_T("Circles"), 4, 4);
  230. m_TreeCtrl.SetItemState(m_hCircles, TVIS_BOLD, TVIS_BOLD);
  231. m_TreeCtrl.SetItemData(m_hCircles, 0);
  232. InitTreeCircleData(dwItemId);
  233. break;
  234. case 4: // Line
  235. m_hLines = m_TreeCtrl.InsertItem(_T("Lines"), 6, 6);
  236. m_TreeCtrl.SetItemState(m_hLines, TVIS_BOLD, TVIS_BOLD);
  237. m_TreeCtrl.SetItemData(m_hLines, 0);
  238. InitTreeLineData(dwItemId);
  239. break;
  240. case 5: // Cylinders
  241. m_hCylinders = m_TreeCtrl.InsertItem(_T("Cylinders"), 8, 8);
  242. m_TreeCtrl.SetItemState(m_hLines, TVIS_BOLD, TVIS_BOLD);
  243. m_TreeCtrl.SetItemData(m_hCylinders, 0);
  244. InitTreeCylinderData(dwItemId);
  245. break;
  246. }
  247. q.nextRow();
  248. }
  249. q.finalize();
  250. }
  251. /**************************************************************************************************
  252. 函 数 名 :InitFormData
  253. 功能描述 :初始化数值
  254. 输入参数 :无
  255. 输出参数 :无
  256. 返 回 值 :void
  257. **************************************************************************************************/
  258. void CStaticTask::InitFormData(DWORD taskId)
  259. {
  260. // 设备IDPMS附加状态为FALSE
  261. m_bIsAttached = FALSE;
  262. this->ResetFormData();
  263. this->m_taskId = taskId;
  264. // 初始化任务信息
  265. InitTaskInfo();
  266. // 初始化UI栏位显示状态
  267. ShowTaskFieldStatus();
  268. // 附加IDPMS窗口到UI
  269. AttachIDPMS();
  270. // 调整IDPMS显示布局
  271. RelayoutIDPMS();
  272. }
  273. /**************************************************************************************************
  274. 函 数 名 :InitTaskInfo
  275. 功能描述 :初始化任务信息
  276. 输入参数 :无
  277. 输出参数 :无
  278. 返 回 值 :void
  279. **************************************************************************************************/
  280. void CStaticTask::InitTaskInfo()
  281. {
  282. // 初始化数据
  283. TaskManager *pTaskManager = m_pDoc->GetTaskManager();
  284. ASSERT(pTaskManager != NULL);
  285. CppSQLite3Query q = pTaskManager->Query(m_taskId);
  286. if (!q.eof()) {
  287. CString szTaskTitle = q.getStringField("task_title");
  288. m_Static_Title.SetWindowText(szTaskTitle);
  289. m_szEquipTypeCode = q.getStringField("equip_type_code");
  290. m_Static_EquipTypeCode.SetWindowText(m_szEquipTypeCode);
  291. m_szEquipCode = q.getStringField("equip_code");
  292. m_Static_EquipCode.SetWindowText(m_szEquipCode);
  293. }
  294. q.finalize();
  295. }
  296. /**************************************************************************************************
  297. 函 数 名 :AttachIDPMS
  298. 功能描述 :附加IDPMS窗口到UI中
  299. 输入参数 :无
  300. 输出参数 :无
  301. 返 回 值 :void
  302. **************************************************************************************************/
  303. void CStaticTask::AttachIDPMS()
  304. {
  305. // 初始化
  306. if (g_hIDPMSHWnd)
  307. {
  308. ::SetParent(g_hIDPMSHWnd, GetDlgItem(IDC_IDPMS_RECT)->m_hWnd);
  309. LONG style=GetWindowLong(g_hIDPMSHWnd ,GWL_STYLE);// 14CF 0000
  310. style &=~WS_CAPTION;
  311. style &=~WS_THICKFRAME;
  312. style |=WS_VISIBLE;
  313. SetWindowLong(g_hIDPMSHWnd, GWL_STYLE, style);//eraze title of ms paint window.
  314. m_bIsAttached = TRUE;
  315. }
  316. }
  317. /**************************************************************************************************
  318. 函 数 名 :RelayoutIDPMS
  319. 功能描述 :调整IDPMS显示布局
  320. 输入参数 :无
  321. 输出参数 :无
  322. 返 回 值 :void
  323. **************************************************************************************************/
  324. void CStaticTask::RelayoutIDPMS()
  325. {
  326. CRect rect;
  327. GetDlgItem(IDC_IDPMS_RECT)->GetWindowRect(&rect);
  328. ScreenToClient(rect);
  329. CRect rectShow;
  330. rectShow.left = 0;
  331. rectShow.top = 0;
  332. rectShow.right = rect.right - rect.left;
  333. rectShow.bottom = rect.bottom - rect.top;
  334. ::MoveWindow(g_hIDPMSHWnd, rectShow.left, rectShow.top, rectShow.right, rectShow.bottom, true);
  335. ::UpdateWindow(g_hIDPMSHWnd);
  336. ::ShowWindow(g_hIDPMSHWnd, SW_SHOW);
  337. ::SwitchToThisWindow(g_hIDPMSHWnd, TRUE);
  338. }
  339. /**************************************************************************************************
  340. 函 数 名 :resetFormData
  341. 功能描述 :重置UI数值
  342. 输入参数 :无
  343. 输出参数 :无
  344. 返 回 值 :void
  345. **************************************************************************************************/
  346. void CStaticTask::ResetFormData()
  347. {
  348. m_hPlanes = NULL;
  349. m_hCircles = NULL;
  350. m_hLines = NULL;
  351. m_hPoints = NULL;
  352. m_hCylinders = NULL;
  353. m_taskId = NULL;
  354. m_szEquipCode = "";
  355. m_szEquipTypeCode = "";
  356. m_iShowType = 0;
  357. m_iTaskStatus = 0;
  358. m_iCS = 0;
  359. m_TreeCtrl.DeleteAllItems();
  360. m_GridCtrl.DeleteAllItems();
  361. // 从IDPMS获取数据
  362. IDPMSManager *pManager = IDPMSManager::GetManager();
  363. BOOL bRet = pManager->CloseIDPMSProject();
  364. if (!bRet) {
  365. LOG::D(_T("IDPMS 通讯异常"));
  366. }
  367. }
  368. /**************************************************************************************************
  369. 函 数 名 :ShowTaskFieldStatus
  370. 功能描述 :初始化UI栏位展示信息
  371. 输入参数 :略
  372. 输出参数 :略
  373. 返 回 值 :略
  374. **************************************************************************************************/
  375. void CStaticTask::ShowTaskFieldStatus()
  376. {
  377. if (m_iTaskStatus == 0) { // 初始状态
  378. m_Btn_Auto.EnableWindow(TRUE);
  379. m_Btn_Report.ShowWindow(SW_HIDE);
  380. m_Btn_Compare.ShowWindow(SW_HIDE);
  381. m_Btn_Update.ShowWindow(SW_HIDE);
  382. }
  383. else if (m_iTaskStatus == 1) // 运行状态
  384. {
  385. m_Btn_Auto.EnableWindow(FALSE);
  386. m_Btn_Report.ShowWindow(SW_HIDE);
  387. m_Btn_Compare.ShowWindow(SW_HIDE);
  388. m_Btn_Update.EnableWindow(FALSE);
  389. }
  390. else if (m_iTaskStatus == 2) // 完成状态
  391. {
  392. m_Btn_Auto.EnableWindow(TRUE);
  393. m_Btn_Report.ShowWindow(SW_SHOW);
  394. m_Btn_Compare.ShowWindow(SW_SHOW);
  395. m_Btn_Update.ShowWindow(SW_SHOW);
  396. m_Btn_Update.EnableWindow(TRUE);
  397. m_Btn_Update.SetWindowText("更新数据");
  398. }
  399. }
  400. /**************************************************************************************************
  401. 函 数 名 :InitTreePlaneData
  402. 功能描述 :初始化设备静态测量数据树状展示
  403. 输入参数 :无
  404. 输出参数 :无
  405. 返 回 值 :void
  406. **************************************************************************************************/
  407. void CStaticTask::InitTreePointData(DWORD iItemId)
  408. {
  409. if (!m_hPoints) return;
  410. // POINT数据访问入口
  411. EquipDataPointManager *pPointManager = m_pDoc->GetEquipDataPointManager();
  412. ASSERT(pPointManager != NULL);
  413. DWORD dwSubItemId;
  414. CString szPointTitle;
  415. CString szPointCode;
  416. HTREEITEM item;
  417. CppSQLite3Query q = pPointManager->Query(m_taskId, m_szEquipCode, iItemId);
  418. while (!q.eof()) {
  419. dwSubItemId = q.getIntField("subitem_id");
  420. szPointTitle = q.getStringField("point_title");
  421. szPointCode = q.getStringField("point_code");
  422. item = m_TreeCtrl.InsertItem(szPointTitle, 1, 1, m_hPoints, TVI_LAST);
  423. m_TreeCtrl.SetItemData(item, dwSubItemId);
  424. q.nextRow();
  425. }
  426. q.finalize();
  427. m_TreeCtrl.Expand(m_hPoints, TVE_EXPAND);
  428. }
  429. /**************************************************************************************************
  430. 函 数 名 :InitTreePlaneData
  431. 功能描述 :初始化设备静态测量数据树状展示
  432. 输入参数 :无
  433. 输出参数 :无
  434. 返 回 值 :void
  435. **************************************************************************************************/
  436. void CStaticTask::InitTreePlaneData(DWORD iItemId)
  437. {
  438. if (!m_hPlanes) return;
  439. // Plane数据访问入口
  440. EquipDataPlaneManager *pPlaneManager = m_pDoc->GetEquipDataPlaneManager();
  441. ASSERT(pPlaneManager != NULL);
  442. DWORD dwSubItemId;
  443. CString szPlaneTitle;
  444. CString szPlaneCode;
  445. HTREEITEM item;
  446. CppSQLite3Query q = pPlaneManager->Query(m_taskId, m_szEquipCode, iItemId);
  447. while (!q.eof()) {
  448. dwSubItemId = q.getIntField("subitem_id");
  449. szPlaneTitle = q.getStringField("plane_title");
  450. szPlaneCode = q.getStringField("plane_code");
  451. item = m_TreeCtrl.InsertItem(szPlaneTitle, 3, 3, m_hPlanes, TVI_LAST);
  452. m_TreeCtrl.SetItemData(item, dwSubItemId);
  453. q.nextRow();
  454. }
  455. q.finalize();
  456. m_TreeCtrl.Expand(m_hPlanes, TVE_EXPAND);
  457. }
  458. /**************************************************************************************************
  459. 函 数 名 :InitTreePlaneData
  460. 功能描述 :初始化设备静态测量数据树状展示
  461. 输入参数 :无
  462. 输出参数 :无
  463. 返 回 值 :void
  464. **************************************************************************************************/
  465. void CStaticTask::InitTreeCircleData(DWORD iItemId)
  466. {
  467. if (!m_hCircles) return;
  468. // Circle数据访问入口
  469. EquipDataCircleManager *pCircleManager = m_pDoc->GetEquipDataCircleManager();
  470. ASSERT(pCircleManager != NULL);
  471. DWORD dwSubItemId;
  472. CString szCircleTitle;
  473. CString szCircleCode;
  474. HTREEITEM item;
  475. CppSQLite3Query q = pCircleManager->Query(m_taskId, m_szEquipCode, iItemId);
  476. while (!q.eof()) {
  477. dwSubItemId = q.getIntField("subitem_id");
  478. szCircleTitle = q.getStringField("circle_title");
  479. szCircleCode = q.getStringField("circle_code");
  480. item = m_TreeCtrl.InsertItem(szCircleTitle, 5, 5, m_hCircles, TVI_LAST);
  481. m_TreeCtrl.SetItemData(item, dwSubItemId);
  482. q.nextRow();
  483. }
  484. q.finalize();
  485. m_TreeCtrl.Expand(m_hCircles, TVE_EXPAND);
  486. }
  487. /**************************************************************************************************
  488. 函 数 名 :InitTreePlaneData
  489. 功能描述 :初始化设备静态测量数据树状展示
  490. 输入参数 :无
  491. 输出参数 :无
  492. 返 回 值 :void
  493. **************************************************************************************************/
  494. void CStaticTask::InitTreeLineData(DWORD iItemId)
  495. {
  496. if (!m_hLines) return;
  497. // LINE数据访问入口
  498. EquipDataLineManager *pLineManager = m_pDoc->GetEquipDataLineManager();
  499. ASSERT(pLineManager != NULL);
  500. DWORD dwSubItemId;
  501. CString szLineTitle;
  502. CString szLineCode;
  503. HTREEITEM item;
  504. CppSQLite3Query q = pLineManager->Query(m_taskId, m_szEquipCode, iItemId);
  505. while (!q.eof()) {
  506. dwSubItemId = q.getIntField("subitem_id");
  507. szLineTitle = q.getStringField("line_title");
  508. szLineCode = q.getStringField("line_code");
  509. item = m_TreeCtrl.InsertItem(szLineTitle, 7, 7, m_hLines, TVI_LAST);
  510. m_TreeCtrl.SetItemData(item, dwSubItemId);
  511. q.nextRow();
  512. }
  513. q.finalize();
  514. m_TreeCtrl.Expand(m_hLines, TVE_EXPAND);
  515. }
  516. /**************************************************************************************************
  517. 函 数 名 :InitTreePlaneData
  518. 功能描述 :初始化设备静态测量数据树状展示
  519. 输入参数 :无
  520. 输出参数 :无
  521. 返 回 值 :void
  522. **************************************************************************************************/
  523. void CStaticTask::InitTreeCylinderData(DWORD iItemId)
  524. {
  525. if (!m_hCylinders) return;
  526. // Circle数据访问入口
  527. EquipDataCylinderManager *pCylinderManager = m_pDoc->GetEquipDataCylinderManager();
  528. ASSERT(pCylinderManager != NULL);
  529. DWORD dwSubItemId;
  530. CString szCylinderTitle;
  531. CString szCylinderCode;
  532. HTREEITEM item;
  533. CppSQLite3Query q = pCylinderManager->Query(m_taskId, m_szEquipCode, iItemId);
  534. while (!q.eof()) {
  535. dwSubItemId = q.getIntField("subitem_id");
  536. szCylinderTitle = q.getStringField("cylinder_title");
  537. szCylinderCode = q.getStringField("cylinder_code");
  538. item = m_TreeCtrl.InsertItem(szCylinderTitle, 9, 9, m_hCylinders, TVI_LAST);
  539. m_TreeCtrl.SetItemData(item, dwSubItemId);
  540. q.nextRow();
  541. }
  542. q.finalize();
  543. m_TreeCtrl.Expand(m_hCylinders, TVE_EXPAND);
  544. }
  545. /**************************************************************************************************
  546. 函 数 名 :OnUpdate
  547. 功能描述 :数据变更,更新UI
  548. 输入参数 :无
  549. 输出参数 :无
  550. 返 回 值 :void
  551. **************************************************************************************************/
  552. void CStaticTask::OnUpdate(CView* /*pSender*/, LPARAM /*lHint*/, CObject* /*pHint*/)
  553. {
  554. }
  555. /**************************************************************************************************
  556. 函 数 名 :OnTvnSelchangedTreeData
  557. 功能描述 :事件处理-点云数据选择
  558. 输入参数 :略
  559. 输出参数 :无
  560. 返 回 值 :void
  561. **************************************************************************************************/
  562. void CStaticTask::OnTvnSelchangedTreeData(NMHDR *pNMHDR, LRESULT *pResult)
  563. {
  564. LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
  565. HTREEITEM item = pNMTreeView->itemNew.hItem;
  566. CString str = m_TreeCtrl.GetItemText(item);
  567. DWORD dwId = (DWORD)m_TreeCtrl.GetItemData(item);
  568. if (dwId == 0) {
  569. *pResult = 1;
  570. return;
  571. }
  572. // 显示选中的数据
  573. ShowData(item);
  574. *pResult = 0;
  575. }
  576. /**************************************************************************************************
  577. 函 数 名 :OnTvnBeginlabeleditTreeData
  578. 功能描述 :事件处理-开始编辑点云数据名称
  579. 输入参数 :略
  580. 输出参数 :无
  581. 返 回 值 :void
  582. **************************************************************************************************/
  583. void CStaticTask::OnTvnBeginlabeleditTreeData(NMHDR *pNMHDR, LRESULT *pResult)
  584. {
  585. LPNMTVDISPINFO pTVDispInfo = reinterpret_cast<LPNMTVDISPINFO>(pNMHDR);
  586. HTREEITEM item = pTVDispInfo->item.hItem;
  587. DWORD dwId = (DWORD)m_TreeCtrl.GetItemData(item);
  588. if (dwId == 0) {
  589. *pResult = 1;
  590. return;
  591. }
  592. CEdit *pEdit = m_TreeCtrl.GetEditControl();
  593. ASSERT(pEdit);
  594. if (pEdit)
  595. {
  596. // 设置结点编辑文本长度不能多于31个字符
  597. pEdit->LimitText(31);
  598. }
  599. *pResult = 0;
  600. }
  601. /**************************************************************************************************
  602. 函 数 名 :OnTvnEndlabeleditTreeData
  603. 功能描述 :事件处理-结束编辑点云数据名称
  604. 输入参数 :略
  605. 输出参数 :无
  606. 返 回 值 :void
  607. **************************************************************************************************/
  608. void CStaticTask::OnTvnEndlabeleditTreeData(NMHDR *pNMHDR, LRESULT *pResult)
  609. {
  610. LPNMTVDISPINFO pTVDispInfo = reinterpret_cast<LPNMTVDISPINFO>(pNMHDR);
  611. HTREEITEM item = pTVDispInfo->item.hItem;
  612. CString strText;
  613. m_TreeCtrl.GetEditControl()->GetWindowText(strText);
  614. BOOL bRet = UpdateDataTitle(item, strText);
  615. if (!bRet)
  616. {
  617. MessageBox(_T("修改失败!"));
  618. *pResult = 1;
  619. return;
  620. }
  621. m_TreeCtrl.SetItemText(item, strText);//设置编辑后的文本为结点
  622. *pResult = 0;
  623. }
  624. /**************************************************************************************************
  625. 函 数 名 :UpdateDataTitle
  626. 功能描述 :事件处理-结束编辑点云数据名称
  627. 输入参数 :略
  628. 输出参数 :无
  629. 返 回 值 :void
  630. **************************************************************************************************/
  631. BOOL CStaticTask::UpdateDataTitle(HTREEITEM hItem, LPCTSTR szTitle)
  632. {
  633. HTREEITEM hParent = m_TreeCtrl.GetParentItem(hItem);
  634. DWORD dwSubitemId = (DWORD)m_TreeCtrl.GetItemData(hItem);
  635. if (hParent == m_hPoints)
  636. {
  637. // POINT数据访问入口
  638. EquipDataPointManager *pPointManager = m_pDoc->GetEquipDataPointManager();
  639. ASSERT(pPointManager != NULL);
  640. return pPointManager->UpdateTitle(m_taskId, m_szEquipCode, 1, dwSubitemId, szTitle);
  641. }
  642. else if (hParent == m_hPlanes)
  643. {
  644. // Plane数据访问入口
  645. EquipDataPlaneManager *pPlaneManager = m_pDoc->GetEquipDataPlaneManager();
  646. ASSERT(pPlaneManager != NULL);
  647. return pPlaneManager->UpdateTitle(m_taskId, m_szEquipCode, 2, dwSubitemId, szTitle);
  648. }
  649. else if (hParent == m_hCircles)
  650. {
  651. // Circle数据访问入口
  652. EquipDataCircleManager *pCircleManager = m_pDoc->GetEquipDataCircleManager();
  653. ASSERT(pCircleManager != NULL);
  654. return pCircleManager->UpdateTitle(m_taskId, m_szEquipCode, 3, dwSubitemId, szTitle);
  655. }
  656. else if (hParent == m_hLines)
  657. {
  658. // LINE数据访问入口
  659. EquipDataLineManager *pLineManager = m_pDoc->GetEquipDataLineManager();
  660. ASSERT(pLineManager != NULL);
  661. return pLineManager->UpdateTitle(m_taskId, m_szEquipCode, 4, dwSubitemId, szTitle);
  662. }
  663. else if (hParent == m_hCylinders)
  664. {
  665. // Cylinder数据访问入口
  666. EquipDataCylinderManager *pCylinderManager = m_pDoc->GetEquipDataCylinderManager();
  667. ASSERT(pCylinderManager != NULL);
  668. return pCylinderManager->UpdateTitle(m_taskId, m_szEquipCode, 5, dwSubitemId, szTitle);
  669. }
  670. return FALSE;
  671. }
  672. /**************************************************************************************************
  673. 函 数 名 :ShowData
  674. 功能描述 :显示数据
  675. 输出参数 :略
  676. 返 回 值 :略
  677. **************************************************************************************************/
  678. void CStaticTask::ShowData(HTREEITEM hItem)
  679. {
  680. // 选中节点的标题
  681. CString szItemTitle = m_TreeCtrl.GetItemText(hItem);
  682. HTREEITEM hParent = m_TreeCtrl.GetParentItem(hItem);
  683. DWORD dwSubitemId = (DWORD)m_TreeCtrl.GetItemData(hItem);
  684. m_dwSubItemId = dwSubitemId;
  685. CString szTitle("");
  686. m_GridCtrl.DeleteAllItems();
  687. m_GridCtrl.SetEditable(FALSE);
  688. m_GridCtrl.GetDefaultCell(FALSE, FALSE)->SetBackClr(RGB(0xFF, 0xFF, 0xFF));
  689. m_GridCtrl.SetAutoSizeStyle();
  690. m_GridCtrl.AutoSize(GVS_HEADER);
  691. m_GridCtrl.SetRowCount(10);
  692. if (hParent == m_hPoints)
  693. {
  694. szTitle.Format("点:%s", szItemTitle);
  695. m_Static_PointTitle.SetWindowText(szTitle);
  696. m_iShowType = 1;
  697. ShowPointData(m_iShowType, dwSubitemId);
  698. }
  699. else if (hParent == m_hPlanes)
  700. {
  701. szTitle.Format("平面:%s", szItemTitle);
  702. m_Static_PointTitle.SetWindowText(szTitle);
  703. m_iShowType = 2;
  704. ShowPlaneData(m_iShowType, dwSubitemId);
  705. }
  706. else if (hParent == m_hCircles)
  707. {
  708. szTitle.Format("圆:%s", szItemTitle);
  709. m_Static_PointTitle.SetWindowText(szTitle);
  710. m_iShowType = 3;
  711. ShowCircleData(m_iShowType, dwSubitemId);
  712. }
  713. else if (hParent == m_hLines)
  714. {
  715. szTitle.Format("直线:%s", szItemTitle);
  716. m_Static_PointTitle.SetWindowText(szTitle);
  717. m_iShowType = 4;
  718. ShowLineData(m_iShowType, dwSubitemId);
  719. }
  720. else if (hParent == m_hCylinders)
  721. {
  722. szTitle.Format("圆柱:%s", szItemTitle);
  723. m_Static_PointTitle.SetWindowText(szTitle);
  724. m_iShowType = 5;
  725. ShowCylinderData(m_iShowType, dwSubitemId);
  726. }
  727. }
  728. /**************************************************************************************************
  729. 函 数 名 :ShowPlaneData
  730. 功能描述 :显示数据-面
  731. 输出参数 :略
  732. 返 回 值 :略
  733. **************************************************************************************************/
  734. void CStaticTask::ShowPlaneData(DWORD dwItemId, DWORD dwSubitemId)
  735. {
  736. TRY
  737. {
  738. m_GridCtrl.SetColumnCount(10);
  739. m_GridCtrl.SetFixedRowCount(1);
  740. m_GridCtrl.SetFixedColumnCount(1);
  741. m_GridCtrl.SetColumnWidth(0, 40);
  742. m_GridCtrl.SetColumnWidth(1, 120);
  743. m_GridCtrl.SetColumnWidth(2, 120);
  744. m_GridCtrl.SetColumnWidth(3, 100);
  745. m_GridCtrl.SetColumnWidth(4, 100);
  746. m_GridCtrl.SetColumnWidth(5, 100);
  747. m_GridCtrl.SetColumnWidth(6, 100);
  748. m_GridCtrl.SetColumnWidth(7, 100);
  749. m_GridCtrl.SetColumnWidth(8, 100);
  750. m_GridCtrl.SetColumnWidth(9, 120);
  751. }
  752. CATCH(CMemoryException, e)
  753. {
  754. e->ReportError();
  755. return;
  756. }
  757. END_CATCH
  758. // Get the font
  759. CFont* pFont = m_GridCtrl.GetFont();
  760. LOGFONT lf;
  761. pFont->GetLogFont(&lf);
  762. // Make it true-type
  763. memcpy(lf.lfFaceName, _T("Arial"), 6);
  764. // Set the fixed row defaults as this new font
  765. m_GridCtrl.GetDefaultCell(TRUE, FALSE)->SetFont(&lf);
  766. CString str;
  767. GV_ITEM ItemTitle;
  768. ItemTitle.mask = GVIF_TEXT | GVIF_FORMAT;
  769. ItemTitle.nBorder = GVIS_BDR_BOTTOM;
  770. ItemTitle.nFormat = DT_SINGLELINE | DT_VCENTER;
  771. ItemTitle.row = 0;
  772. ItemTitle.col = 0;
  773. ItemTitle.nFormat = DT_CENTER;
  774. str.Format(_T("序号"));
  775. ItemTitle.strText = str;
  776. m_GridCtrl.SetItem(&ItemTitle);
  777. ItemTitle.row = 0;
  778. ItemTitle.col = 1;
  779. ItemTitle.nFormat = DT_CENTER;
  780. str.Format(_T("名称"));
  781. ItemTitle.strText = str;
  782. m_GridCtrl.SetItem(&ItemTitle);
  783. ItemTitle.row = 0;
  784. ItemTitle.col = 2;
  785. ItemTitle.nFormat = DT_CENTER;
  786. str.Format(_T("编码"));
  787. ItemTitle.strText = str;
  788. m_GridCtrl.SetItem(&ItemTitle);
  789. ItemTitle.row = 0;
  790. ItemTitle.col = 3;
  791. ItemTitle.nFormat = DT_RIGHT;
  792. str.Format(_T("A"));
  793. ItemTitle.strText = str;
  794. m_GridCtrl.SetItem(&ItemTitle);
  795. ItemTitle.row = 0;
  796. ItemTitle.col = 4;
  797. ItemTitle.nFormat = DT_RIGHT;
  798. str.Format(_T("B"));
  799. ItemTitle.strText = str;
  800. m_GridCtrl.SetItem(&ItemTitle);
  801. ItemTitle.row = 0;
  802. ItemTitle.col = 5;
  803. ItemTitle.nFormat = DT_RIGHT;
  804. str.Format(_T("C"));
  805. ItemTitle.strText = str;
  806. m_GridCtrl.SetItem(&ItemTitle);
  807. ItemTitle.row = 0;
  808. ItemTitle.col = 6;
  809. ItemTitle.nFormat = DT_RIGHT;
  810. str.Format(_T("D"));
  811. ItemTitle.strText = str;
  812. m_GridCtrl.SetItem(&ItemTitle);
  813. ItemTitle.row = 0;
  814. ItemTitle.col = 7;
  815. ItemTitle.nFormat = DT_RIGHT;
  816. str.Format(_T("RMS"));
  817. ItemTitle.strText = str;
  818. m_GridCtrl.SetItem(&ItemTitle);
  819. ItemTitle.row = 0;
  820. ItemTitle.col = 8;
  821. ItemTitle.nFormat = DT_RIGHT;
  822. str.Format(_T("平面度"));
  823. ItemTitle.strText = str;
  824. m_GridCtrl.SetItem(&ItemTitle);
  825. ItemTitle.row = 0;
  826. ItemTitle.col = 9;
  827. ItemTitle.nFormat = DT_LEFT;
  828. str.Format(_T("说明"));
  829. ItemTitle.strText = str;
  830. m_GridCtrl.SetItem(&ItemTitle);
  831. // Plane数据访问入口
  832. EquipDataPlaneManager *pPlaneManager = m_pDoc->GetEquipDataPlaneManager();
  833. ASSERT(pPlaneManager != NULL);
  834. GV_ITEM Item;
  835. Item.mask = GVIF_TEXT | GVIF_FORMAT;
  836. Item.nFormat = DT_SINGLELINE | DT_VCENTER;
  837. int iRow = 1;
  838. int iIndex = 0;
  839. CppSQLite3Query q = pPlaneManager->Query(m_taskId, m_szEquipCode, dwItemId, dwSubitemId);
  840. while (!q.eof()) {
  841. iIndex += 1;
  842. // 序号
  843. Item.row = iRow;
  844. Item.col = 0;
  845. Item.nFormat = DT_CENTER;
  846. str.Format("%d", iIndex);
  847. Item.strText = str;
  848. m_GridCtrl.SetItem(&Item);
  849. // 名称
  850. Item.row = iRow;
  851. Item.col = 1;
  852. Item.nFormat = DT_CENTER;
  853. str.Format("%s", q.getStringField("plane_title"));
  854. Item.strText = str;
  855. m_GridCtrl.SetItem(&Item);
  856. // CODE
  857. Item.row = iRow;
  858. Item.col = 2;
  859. Item.nFormat = DT_CENTER;
  860. str.Format("%s", q.getStringField("plane_code"));
  861. Item.strText = str;
  862. m_GridCtrl.SetItem(&Item);
  863. // A
  864. Item.row = iRow;
  865. Item.col = 3;
  866. Item.nFormat = DT_RIGHT;
  867. str.Format("%.3f", q.getFloatField("plane_a"));
  868. Item.strText = str;
  869. m_GridCtrl.SetItem(&Item);
  870. // B
  871. Item.row = iRow;
  872. Item.col = 4;
  873. Item.nFormat = DT_RIGHT;
  874. str.Format("%.3f", q.getFloatField("plane_b"));
  875. Item.strText = str;
  876. m_GridCtrl.SetItem(&Item);
  877. // C
  878. Item.row = iRow;
  879. Item.col = 5;
  880. Item.nFormat = DT_RIGHT;
  881. str.Format("%.3f", q.getFloatField("plane_c"));
  882. Item.strText = str;
  883. m_GridCtrl.SetItem(&Item);
  884. // D
  885. Item.row = iRow;
  886. Item.col = 6;
  887. Item.nFormat = DT_RIGHT;
  888. str.Format("%.3f", q.getFloatField("plane_d"));
  889. Item.strText = str;
  890. m_GridCtrl.SetItem(&Item);
  891. // RMS
  892. Item.row = iRow;
  893. Item.col = 7;
  894. Item.nFormat = DT_RIGHT;
  895. str.Format("%.3f", q.getFloatField("plane_rms"));
  896. Item.strText = str;
  897. m_GridCtrl.SetItem(&Item);
  898. // 平面度
  899. Item.row = iRow;
  900. Item.col = 8;
  901. Item.nFormat = DT_RIGHT;
  902. str.Format("%.3f", q.getFloatField("plane_flatness"));
  903. Item.strText = str;
  904. m_GridCtrl.SetItem(&Item);
  905. // DESC
  906. Item.row = iRow;
  907. Item.col = 9;
  908. Item.nFormat = DT_LEFT;
  909. str.Format("%s", q.getStringField("plane_desc"));
  910. Item.strText = str;
  911. m_GridCtrl.SetItem(&Item);
  912. iRow++;
  913. q.nextRow();
  914. }
  915. q.finalize();
  916. }
  917. /**************************************************************************************************
  918. 函 数 名 :ShowCircleData
  919. 功能描述 :显示数据-圆
  920. 输出参数 :略
  921. 返 回 值 :略
  922. **************************************************************************************************/
  923. void CStaticTask::ShowCircleData(DWORD dwItemId, DWORD dwSubitemId)
  924. {
  925. TRY
  926. {
  927. m_GridCtrl.SetColumnCount(10);
  928. m_GridCtrl.SetFixedRowCount(2);
  929. m_GridCtrl.SetFixedColumnCount(1);
  930. m_GridCtrl.SetColumnWidth(0, 40);
  931. m_GridCtrl.SetColumnWidth(1, 120);
  932. m_GridCtrl.SetColumnWidth(2, 120);
  933. m_GridCtrl.SetColumnWidth(3, 100);
  934. m_GridCtrl.SetColumnWidth(4, 100);
  935. m_GridCtrl.SetColumnWidth(5, 100);
  936. m_GridCtrl.SetColumnWidth(6, 100);
  937. m_GridCtrl.SetColumnWidth(7, 100);
  938. m_GridCtrl.SetColumnWidth(8, 100);
  939. m_GridCtrl.SetColumnWidth(9, 120);
  940. }
  941. CATCH(CMemoryException, e)
  942. {
  943. e->ReportError();
  944. return;
  945. }
  946. END_CATCH
  947. // Get the font
  948. CFont* pFont = m_GridCtrl.GetFont();
  949. LOGFONT lf;
  950. pFont->GetLogFont(&lf);
  951. // Make it true-type
  952. memcpy(lf.lfFaceName, _T("Arial"), 6);
  953. // Set the fixed row defaults as this new font
  954. m_GridCtrl.GetDefaultCell(TRUE, FALSE)->SetFont(&lf);
  955. CString str;
  956. GV_ITEM ItemTitle;
  957. ItemTitle.mask = GVIF_TEXT | GVIF_FORMAT;
  958. ItemTitle.nBorder = GVIS_BDR_BOTTOM;
  959. ItemTitle.nFormat = DT_SINGLELINE | DT_VCENTER;
  960. ItemTitle.row = 0;
  961. ItemTitle.col = 0;
  962. ItemTitle.nFormat = DT_CENTER;
  963. ItemTitle.strText = _T("序号");
  964. m_GridCtrl.SetItem(&ItemTitle);
  965. m_GridCtrl.MergeCells(0, 0, 1, 0);
  966. ItemTitle.row = 0;
  967. ItemTitle.col = 1;
  968. ItemTitle.nFormat = DT_CENTER;
  969. ItemTitle.strText = _T("名称");
  970. m_GridCtrl.SetItem(&ItemTitle);
  971. m_GridCtrl.MergeCells(0, 1, 1, 1);
  972. ItemTitle.row = 0;
  973. ItemTitle.col = 2;
  974. ItemTitle.nFormat = DT_CENTER;
  975. ItemTitle.strText = _T("编码");
  976. m_GridCtrl.SetItem(&ItemTitle);
  977. m_GridCtrl.MergeCells(0, 2, 1, 2);
  978. ItemTitle.row = 0;
  979. ItemTitle.col = 3;
  980. ItemTitle.nFormat = DT_CENTER;
  981. ItemTitle.strText = _T("圆心");
  982. m_GridCtrl.SetItem(&ItemTitle);
  983. m_GridCtrl.MergeCells(0, 3, 0, 5);
  984. CString szX;
  985. CString szY;
  986. CString szZ;
  987. if (m_iCS == 0) {
  988. szX.Format("%s", "X");
  989. szY.Format("%s", "Y");
  990. szZ.Format("%s", "Z");
  991. }
  992. else if (m_iCS == 1)
  993. {
  994. szX.Format("%s", "R");
  995. szY.Format("%s", "θ");
  996. szZ.Format("%s", "φ");
  997. }
  998. else if (m_iCS == 2)
  999. {
  1000. szX.Format("%s", "R");
  1001. szY.Format("%s", "θ");
  1002. szZ.Format("%s", "Z");
  1003. }
  1004. ItemTitle.row = 1;
  1005. ItemTitle.col = 3;
  1006. ItemTitle.nFormat = DT_CENTER;
  1007. ItemTitle.strText = szX;
  1008. m_GridCtrl.SetItem(&ItemTitle);
  1009. ItemTitle.row = 1;
  1010. ItemTitle.col = 4;
  1011. ItemTitle.nFormat = DT_CENTER;
  1012. ItemTitle.strText = szY;
  1013. m_GridCtrl.SetItem(&ItemTitle);
  1014. ItemTitle.row = 1;
  1015. ItemTitle.col = 5;
  1016. ItemTitle.nFormat = DT_CENTER;
  1017. ItemTitle.strText = szZ;
  1018. m_GridCtrl.SetItem(&ItemTitle);
  1019. ItemTitle.row = 0;
  1020. ItemTitle.col = 6;
  1021. ItemTitle.nFormat = DT_CENTER;
  1022. ItemTitle.strText = _T("半径");
  1023. m_GridCtrl.SetItem(&ItemTitle);
  1024. m_GridCtrl.MergeCells(0, 6, 1, 6);
  1025. ItemTitle.row = 0;
  1026. ItemTitle.col = 7;
  1027. ItemTitle.nFormat = DT_CENTER;
  1028. ItemTitle.strText = _T("RMS");
  1029. m_GridCtrl.SetItem(&ItemTitle);
  1030. m_GridCtrl.MergeCells(0, 7, 1, 7);
  1031. ItemTitle.row = 0;
  1032. ItemTitle.col = 8;
  1033. ItemTitle.nFormat = DT_CENTER;
  1034. ItemTitle.strText = _T("圆度");
  1035. m_GridCtrl.SetItem(&ItemTitle);
  1036. m_GridCtrl.MergeCells(0, 8, 1, 8);
  1037. ItemTitle.row = 0;
  1038. ItemTitle.col = 9;
  1039. ItemTitle.nFormat = DT_LEFT;
  1040. ItemTitle.strText = _T("说明");
  1041. m_GridCtrl.SetItem(&ItemTitle);
  1042. m_GridCtrl.MergeCells(0, 9, 1, 9);
  1043. // Circle数据访问入口
  1044. EquipDataCircleManager *pCircleManager = m_pDoc->GetEquipDataCircleManager();
  1045. ASSERT(pCircleManager != NULL);
  1046. GV_ITEM Item;
  1047. Item.mask = GVIF_TEXT | GVIF_FORMAT;
  1048. Item.nFormat = DT_SINGLELINE | DT_VCENTER;
  1049. int iRow = 2;
  1050. int iIndex = 0;
  1051. CppSQLite3Query q = pCircleManager->Query(m_taskId, m_szEquipCode,dwItemId, dwSubitemId);
  1052. while (!q.eof()) {
  1053. iIndex += 1;
  1054. // 序号
  1055. Item.row = iRow;
  1056. Item.col = 0;
  1057. Item.nFormat = DT_CENTER;
  1058. str.Format("%d", iIndex);
  1059. Item.strText = str;
  1060. m_GridCtrl.SetItem(&Item);
  1061. // 名称
  1062. Item.row = iRow;
  1063. Item.col = 1;
  1064. Item.nFormat = DT_CENTER;
  1065. str.Format("%s", q.getStringField("circle_title"));
  1066. Item.strText = str;
  1067. m_GridCtrl.SetItem(&Item);
  1068. // CODE
  1069. Item.row = iRow;
  1070. Item.col = 2;
  1071. Item.nFormat = DT_CENTER;
  1072. str.Format("%s", q.getStringField("circle_code"));
  1073. Item.strText = str;
  1074. m_GridCtrl.SetItem(&Item);
  1075. // 圆心作坐标系切换
  1076. DOUBLE x = q.getFloatField("circle_center_x");
  1077. DOUBLE y = q.getFloatField("circle_center_y");
  1078. DOUBLE z = q.getFloatField("circle_center_z");
  1079. CoordCartesian ctsPoint;
  1080. ctsPoint.x = x;
  1081. ctsPoint.y = y;
  1082. ctsPoint.z = z;
  1083. if (m_iCS == 1)
  1084. {
  1085. CoordSpherical cdsPoint;
  1086. CS::CartesianToSpherical(ctsPoint, cdsPoint);
  1087. x = cdsPoint.r;
  1088. y = cdsPoint.θ;
  1089. z = cdsPoint.φ;
  1090. }
  1091. else if (m_iCS == 2)
  1092. {
  1093. CoordCylindrical ccdPoint;
  1094. CS::CartesianToCylindrical(ctsPoint, ccdPoint);
  1095. x = ccdPoint.r;
  1096. y = ccdPoint.θ;
  1097. z = ccdPoint.z;
  1098. }
  1099. // 圆心 - X
  1100. Item.row = iRow;
  1101. Item.col = 3;
  1102. Item.nFormat = DT_RIGHT;
  1103. str.Format("%.3f", x);
  1104. Item.strText = str;
  1105. m_GridCtrl.SetItem(&Item);
  1106. // 圆心 - Y
  1107. Item.row = iRow;
  1108. Item.col = 4;
  1109. Item.nFormat = DT_RIGHT;
  1110. str.Format("%.3f", y);
  1111. Item.strText = str;
  1112. m_GridCtrl.SetItem(&Item);
  1113. // 圆心 - Z
  1114. Item.row = iRow;
  1115. Item.col = 5;
  1116. Item.nFormat = DT_RIGHT;
  1117. str.Format("%.3f", z);
  1118. Item.strText = str;
  1119. m_GridCtrl.SetItem(&Item);
  1120. // 半径
  1121. Item.row = iRow;
  1122. Item.col = 6;
  1123. Item.nFormat = DT_RIGHT;
  1124. str.Format("%.3f", q.getFloatField("circle_radius"));
  1125. Item.strText = str;
  1126. m_GridCtrl.SetItem(&Item);
  1127. // RMS
  1128. Item.row = iRow;
  1129. Item.col = 7;
  1130. Item.nFormat = DT_RIGHT;
  1131. str.Format("%.3f", q.getFloatField("circle_rms"));
  1132. Item.strText = str;
  1133. m_GridCtrl.SetItem(&Item);
  1134. // 圆度
  1135. Item.row = iRow;
  1136. Item.col = 8;
  1137. Item.nFormat = DT_RIGHT;
  1138. str.Format("%.3f", q.getFloatField("circle_roundness"));
  1139. Item.strText = str;
  1140. m_GridCtrl.SetItem(&Item);
  1141. // DESC
  1142. Item.row = iRow;
  1143. Item.col = 9;
  1144. Item.nFormat = DT_LEFT;
  1145. str.Format("%s", q.getStringField("circle_desc"));
  1146. Item.strText = str;
  1147. m_GridCtrl.SetItem(&Item);
  1148. iRow++;
  1149. q.nextRow();
  1150. }
  1151. q.finalize();
  1152. }
  1153. /**************************************************************************************************
  1154. 函 数 名 :ShowLineData
  1155. 功能描述 :显示数据-直线
  1156. 输出参数 :略
  1157. 返 回 值 :略
  1158. **************************************************************************************************/
  1159. void CStaticTask::ShowLineData(DWORD dwItemId, DWORD dwSubitemId)
  1160. {
  1161. TRY
  1162. {
  1163. m_GridCtrl.SetColumnCount(14);
  1164. m_GridCtrl.SetFixedRowCount(2);
  1165. m_GridCtrl.SetFixedColumnCount(1);
  1166. m_GridCtrl.SetColumnWidth(0, 40);
  1167. m_GridCtrl.SetColumnWidth(1, 100);
  1168. m_GridCtrl.SetColumnWidth(2, 100);
  1169. m_GridCtrl.SetColumnWidth(3, 70);
  1170. m_GridCtrl.SetColumnWidth(4, 70);
  1171. m_GridCtrl.SetColumnWidth(5, 70);
  1172. m_GridCtrl.SetColumnWidth(6, 70);
  1173. m_GridCtrl.SetColumnWidth(7, 70);
  1174. m_GridCtrl.SetColumnWidth(8, 70);
  1175. m_GridCtrl.SetColumnWidth(9, 70);
  1176. m_GridCtrl.SetColumnWidth(10, 70);
  1177. m_GridCtrl.SetColumnWidth(11, 70);
  1178. m_GridCtrl.SetColumnWidth(12, 70);
  1179. m_GridCtrl.SetColumnWidth(13, 100);
  1180. }
  1181. CATCH(CMemoryException, e)
  1182. {
  1183. e->ReportError();
  1184. return;
  1185. }
  1186. END_CATCH
  1187. // 坐标系参数名称
  1188. CString szX;
  1189. CString szY;
  1190. CString szZ;
  1191. if (m_iCS == 0) {
  1192. szX.Format("%s", "X");
  1193. szY.Format("%s", "Y");
  1194. szZ.Format("%s", "Z");
  1195. }
  1196. else if (m_iCS == 1)
  1197. {
  1198. szX.Format("%s", "R");
  1199. szY.Format("%s", "θ");
  1200. szZ.Format("%s", "φ");
  1201. }
  1202. else if (m_iCS == 2)
  1203. {
  1204. szX.Format("%s", "R");
  1205. szY.Format("%s", "θ");
  1206. szZ.Format("%s", "Z");
  1207. }
  1208. // Get the font
  1209. CFont* pFont = m_GridCtrl.GetFont();
  1210. LOGFONT lf;
  1211. pFont->GetLogFont(&lf);
  1212. // Make it true-type
  1213. memcpy(lf.lfFaceName, _T("Arial"), 6);
  1214. // Set the fixed row defaults as this new font
  1215. m_GridCtrl.GetDefaultCell(TRUE, FALSE)->SetFont(&lf);
  1216. CString str;
  1217. GV_ITEM ItemTitle;
  1218. ItemTitle.mask = GVIF_TEXT | GVIF_FORMAT;
  1219. ItemTitle.nBorder = GVIS_BDR_BOTTOM;
  1220. ItemTitle.nFormat = DT_SINGLELINE | DT_VCENTER;
  1221. ItemTitle.row = 0;
  1222. ItemTitle.col = 0;
  1223. ItemTitle.nFormat = DT_CENTER;
  1224. str.Format(_T("序号"));
  1225. ItemTitle.strText = str;
  1226. m_GridCtrl.SetItem(&ItemTitle);
  1227. m_GridCtrl.MergeCells(0, 0, 1, 0);
  1228. ItemTitle.row = 0;
  1229. ItemTitle.col = 1;
  1230. ItemTitle.nFormat = DT_CENTER;
  1231. str.Format(_T("名称"));
  1232. ItemTitle.strText = str;
  1233. m_GridCtrl.SetItem(&ItemTitle);
  1234. m_GridCtrl.MergeCells(0, 1, 1, 1);
  1235. ItemTitle.row = 0;
  1236. ItemTitle.col = 2;
  1237. ItemTitle.nFormat = DT_CENTER;
  1238. str.Format(_T("编码"));
  1239. ItemTitle.strText = str;
  1240. m_GridCtrl.SetItem(&ItemTitle);
  1241. m_GridCtrl.MergeCells(0, 2, 1, 2);
  1242. ItemTitle.row = 0;
  1243. ItemTitle.col = 3;
  1244. ItemTitle.nFormat = DT_CENTER;
  1245. str.Format(_T("向量"));
  1246. ItemTitle.strText = str;
  1247. m_GridCtrl.SetItem(&ItemTitle);
  1248. m_GridCtrl.MergeCells(0, 3, 0, 5);
  1249. ItemTitle.row = 1;
  1250. ItemTitle.col = 3;
  1251. ItemTitle.nFormat = DT_CENTER;
  1252. ItemTitle.strText = szX;
  1253. m_GridCtrl.SetItem(&ItemTitle);
  1254. ItemTitle.row = 1;
  1255. ItemTitle.col = 4;
  1256. ItemTitle.nFormat = DT_CENTER;
  1257. ItemTitle.strText = szY;
  1258. m_GridCtrl.SetItem(&ItemTitle);
  1259. ItemTitle.row = 1;
  1260. ItemTitle.col = 5;
  1261. ItemTitle.nFormat = DT_CENTER;
  1262. ItemTitle.strText = szZ;
  1263. m_GridCtrl.SetItem(&ItemTitle);
  1264. ItemTitle.row = 0;
  1265. ItemTitle.col = 6;
  1266. ItemTitle.nFormat = DT_CENTER;
  1267. ItemTitle.strText = _T("起点");
  1268. m_GridCtrl.SetItem(&ItemTitle);
  1269. m_GridCtrl.MergeCells(0, 6, 0, 8);
  1270. ItemTitle.row = 1;
  1271. ItemTitle.col = 6;
  1272. ItemTitle.nFormat = DT_CENTER;
  1273. ItemTitle.strText = szX;
  1274. m_GridCtrl.SetItem(&ItemTitle);
  1275. ItemTitle.row = 1;
  1276. ItemTitle.col = 7;
  1277. ItemTitle.nFormat = DT_CENTER;
  1278. ItemTitle.strText = szY;
  1279. m_GridCtrl.SetItem(&ItemTitle);
  1280. ItemTitle.row = 1;
  1281. ItemTitle.col = 8;
  1282. ItemTitle.nFormat = DT_CENTER;
  1283. ItemTitle.strText = szZ;
  1284. m_GridCtrl.SetItem(&ItemTitle);
  1285. ItemTitle.row = 0;
  1286. ItemTitle.col = 9;
  1287. ItemTitle.nFormat = DT_CENTER;
  1288. ItemTitle.strText = _T("终点");
  1289. m_GridCtrl.SetItem(&ItemTitle);
  1290. m_GridCtrl.MergeCells(0, 9, 0, 11);
  1291. ItemTitle.row = 1;
  1292. ItemTitle.col = 9;
  1293. ItemTitle.nFormat = DT_CENTER;
  1294. ItemTitle.strText = szX;
  1295. m_GridCtrl.SetItem(&ItemTitle);
  1296. ItemTitle.row = 1;
  1297. ItemTitle.col = 10;
  1298. ItemTitle.nFormat = DT_CENTER;
  1299. ItemTitle.strText = szY;
  1300. m_GridCtrl.SetItem(&ItemTitle);
  1301. ItemTitle.row = 1;
  1302. ItemTitle.col = 11;
  1303. ItemTitle.nFormat = DT_CENTER;
  1304. ItemTitle.strText = szZ;
  1305. m_GridCtrl.SetItem(&ItemTitle);
  1306. ItemTitle.row = 0;
  1307. ItemTitle.col = 12;
  1308. ItemTitle.nFormat = DT_CENTER;
  1309. str.Format(_T("长度"));
  1310. ItemTitle.strText = str;
  1311. m_GridCtrl.SetItem(&ItemTitle);
  1312. m_GridCtrl.MergeCells(0, 12, 1, 12);
  1313. ItemTitle.row = 0;
  1314. ItemTitle.col = 13;
  1315. ItemTitle.nFormat = DT_LEFT;
  1316. str.Format(_T("说明"));
  1317. ItemTitle.strText = str;
  1318. m_GridCtrl.SetItem(&ItemTitle);
  1319. m_GridCtrl.MergeCells(0, 13, 1, 13);
  1320. // LINE数据访问入口
  1321. EquipDataLineManager *pLineManager = m_pDoc->GetEquipDataLineManager();
  1322. ASSERT(pLineManager != NULL);
  1323. GV_ITEM Item;
  1324. Item.mask = GVIF_TEXT | GVIF_FORMAT;
  1325. Item.nFormat = DT_SINGLELINE | DT_VCENTER;
  1326. int iRow = 2;
  1327. int iIndex = 0;
  1328. CppSQLite3Query q = pLineManager->Query(m_taskId, m_szEquipCode, dwItemId, dwSubitemId);
  1329. while (!q.eof()) {
  1330. iIndex += 1;
  1331. // 序号
  1332. Item.row = iRow;
  1333. Item.col = 0;
  1334. Item.nFormat = DT_CENTER;
  1335. str.Format("%d", iIndex);
  1336. Item.strText = str;
  1337. m_GridCtrl.SetItem(&Item);
  1338. // 名称
  1339. Item.row = iRow;
  1340. Item.col = 1;
  1341. Item.nFormat = DT_CENTER;
  1342. str.Format("%s", q.getStringField("line_title"));
  1343. Item.strText = str;
  1344. m_GridCtrl.SetItem(&Item);
  1345. // CODE
  1346. Item.row = iRow;
  1347. Item.col = 2;
  1348. Item.nFormat = DT_CENTER;
  1349. str.Format("%s", q.getStringField("line_code"));
  1350. Item.strText = str;
  1351. m_GridCtrl.SetItem(&Item);
  1352. /***********************************************************************************/
  1353. // 向量进行坐标系切换
  1354. DOUBLE x = q.getFloatField("line_vec_x");
  1355. DOUBLE y = q.getFloatField("line_vec_y");
  1356. DOUBLE z = q.getFloatField("line_vec_z");
  1357. CoordCartesian ctsPoint;
  1358. ctsPoint.x = x;
  1359. ctsPoint.y = y;
  1360. ctsPoint.z = z;
  1361. if (m_iCS == 1)
  1362. {
  1363. CoordSpherical cdsPoint;
  1364. CS::CartesianToSpherical(ctsPoint, cdsPoint);
  1365. x = cdsPoint.r;
  1366. y = cdsPoint.θ;
  1367. z = cdsPoint.φ;
  1368. }
  1369. else if (m_iCS == 2)
  1370. {
  1371. CoordCylindrical ccdPoint;
  1372. CS::CartesianToCylindrical(ctsPoint, ccdPoint);
  1373. x = ccdPoint.r;
  1374. y = ccdPoint.θ;
  1375. z = ccdPoint.z;
  1376. }
  1377. // 向量 - X
  1378. Item.row = iRow;
  1379. Item.col = 3;
  1380. Item.nFormat = DT_RIGHT;
  1381. str.Format("%.3f", x);
  1382. Item.strText = str;
  1383. m_GridCtrl.SetItem(&Item);
  1384. // 向量 - Y
  1385. Item.row = iRow;
  1386. Item.col = 4;
  1387. Item.nFormat = DT_RIGHT;
  1388. str.Format("%.3f", y);
  1389. Item.strText = str;
  1390. m_GridCtrl.SetItem(&Item);
  1391. // 向量 - Z
  1392. Item.row = iRow;
  1393. Item.col = 5;
  1394. Item.nFormat = DT_RIGHT;
  1395. str.Format("%.3f", z);
  1396. Item.strText = str;
  1397. m_GridCtrl.SetItem(&Item);
  1398. /***********************************************************************************/
  1399. // 起点进行坐标系切换
  1400. x = q.getFloatField("line_start_x");
  1401. y = q.getFloatField("line_start_y");
  1402. z = q.getFloatField("line_start_z");
  1403. ctsPoint.x = x;
  1404. ctsPoint.y = y;
  1405. ctsPoint.z = z;
  1406. if (m_iCS == 1)
  1407. {
  1408. CoordSpherical cdsPoint;
  1409. CS::CartesianToSpherical(ctsPoint, cdsPoint);
  1410. x = cdsPoint.r;
  1411. y = cdsPoint.θ;
  1412. z = cdsPoint.φ;
  1413. }
  1414. else if (m_iCS == 2)
  1415. {
  1416. CoordCylindrical ccdPoint;
  1417. CS::CartesianToCylindrical(ctsPoint, ccdPoint);
  1418. x = ccdPoint.r;
  1419. y = ccdPoint.θ;
  1420. z = ccdPoint.z;
  1421. }
  1422. // 起点 - X
  1423. Item.row = iRow;
  1424. Item.col = 6;
  1425. Item.nFormat = DT_RIGHT;
  1426. str.Format("%.3f", x);
  1427. Item.strText = str;
  1428. m_GridCtrl.SetItem(&Item);
  1429. // 起点 - Y
  1430. Item.row = iRow;
  1431. Item.col = 7;
  1432. Item.nFormat = DT_RIGHT;
  1433. str.Format("%.3f", y);
  1434. Item.strText = str;
  1435. m_GridCtrl.SetItem(&Item);
  1436. // 起点 - Z
  1437. Item.row = iRow;
  1438. Item.col = 8;
  1439. Item.nFormat = DT_RIGHT;
  1440. str.Format("%.3f", z);
  1441. Item.strText = str;
  1442. m_GridCtrl.SetItem(&Item);
  1443. /********************************************************************************/
  1444. // 终点进行坐标系切换
  1445. x = q.getFloatField("line_end_x");
  1446. y = q.getFloatField("line_end_y");
  1447. z = q.getFloatField("line_end_z");
  1448. ctsPoint.x = x;
  1449. ctsPoint.y = y;
  1450. ctsPoint.z = z;
  1451. if (m_iCS == 1)
  1452. {
  1453. CoordSpherical cdsPoint;
  1454. CS::CartesianToSpherical(ctsPoint, cdsPoint);
  1455. x = cdsPoint.r;
  1456. y = cdsPoint.θ;
  1457. z = cdsPoint.φ;
  1458. }
  1459. else if (m_iCS == 2)
  1460. {
  1461. CoordCylindrical ccdPoint;
  1462. CS::CartesianToCylindrical(ctsPoint, ccdPoint);
  1463. x = ccdPoint.r;
  1464. y = ccdPoint.θ;
  1465. z = ccdPoint.z;
  1466. }
  1467. // 终点 - X
  1468. Item.row = iRow;
  1469. Item.col = 9;
  1470. Item.nFormat = DT_RIGHT;
  1471. str.Format("%.3f", x);
  1472. Item.strText = str;
  1473. m_GridCtrl.SetItem(&Item);
  1474. // 终点 - Y
  1475. Item.row = iRow;
  1476. Item.col = 10;
  1477. Item.nFormat = DT_RIGHT;
  1478. str.Format("%.3f", y);
  1479. Item.strText = str;
  1480. m_GridCtrl.SetItem(&Item);
  1481. // 终点 - Z
  1482. Item.row = iRow;
  1483. Item.col = 11;
  1484. Item.nFormat = DT_RIGHT;
  1485. str.Format("%.3f", z);
  1486. Item.strText = str;
  1487. m_GridCtrl.SetItem(&Item);
  1488. /***********************************************************************************/
  1489. // 长度
  1490. Item.row = iRow;
  1491. Item.col = 12;
  1492. Item.nFormat = DT_RIGHT;
  1493. str.Format("%.3f", q.getFloatField("line_length"));
  1494. Item.strText = str;
  1495. m_GridCtrl.SetItem(&Item);
  1496. // 说明
  1497. Item.row = iRow;
  1498. Item.col = 13;
  1499. Item.nFormat = DT_LEFT;
  1500. str.Format("%s", q.getStringField("line_desc"));
  1501. Item.strText = str;
  1502. m_GridCtrl.SetItem(&Item);
  1503. iRow++;
  1504. q.nextRow();
  1505. }
  1506. q.finalize();
  1507. }
  1508. /**************************************************************************************************
  1509. 函 数 名 :ShowPointsData
  1510. 功能描述 :显示数据-点
  1511. 输出参数 :略
  1512. 返 回 值 :略
  1513. **************************************************************************************************/
  1514. void CStaticTask::ShowPointData(DWORD dwItemId, DWORD dwSubitemId)
  1515. {
  1516. TRY
  1517. {
  1518. m_GridCtrl.SetColumnCount(10);
  1519. m_GridCtrl.SetFixedRowCount(2);
  1520. m_GridCtrl.SetFixedColumnCount(1);
  1521. m_GridCtrl.SetColumnWidth(0, 40);
  1522. m_GridCtrl.SetColumnWidth(1, 100);
  1523. m_GridCtrl.SetColumnWidth(2, 100);
  1524. m_GridCtrl.SetColumnWidth(3, 80);
  1525. m_GridCtrl.SetColumnWidth(4, 80);
  1526. m_GridCtrl.SetColumnWidth(5, 80);
  1527. m_GridCtrl.SetColumnWidth(6, 80);
  1528. m_GridCtrl.SetColumnWidth(7, 80);
  1529. m_GridCtrl.SetColumnWidth(8, 80);
  1530. m_GridCtrl.SetColumnWidth(9, 100);
  1531. }
  1532. CATCH(CMemoryException, e)
  1533. {
  1534. e->ReportError();
  1535. return;
  1536. }
  1537. END_CATCH
  1538. // 坐标系参数名称
  1539. CString szX;
  1540. CString szY;
  1541. CString szZ;
  1542. if (m_iCS == 0) {
  1543. szX.Format("%s", "X");
  1544. szY.Format("%s", "Y");
  1545. szZ.Format("%s", "Z");
  1546. }
  1547. else if (m_iCS == 1)
  1548. {
  1549. szX.Format("%s", "R");
  1550. szY.Format("%s", "θ");
  1551. szZ.Format("%s", "φ");
  1552. }
  1553. else if (m_iCS == 2)
  1554. {
  1555. szX.Format("%s", "R");
  1556. szY.Format("%s", "θ");
  1557. szZ.Format("%s", "Z");
  1558. }
  1559. // Get the font
  1560. CFont* pFont = m_GridCtrl.GetFont();
  1561. LOGFONT lf;
  1562. pFont->GetLogFont(&lf);
  1563. // Make it true-type
  1564. memcpy(lf.lfFaceName, _T("Arial"), 6);
  1565. // Set the fixed row defaults as this new font
  1566. m_GridCtrl.GetDefaultCell(TRUE, FALSE)->SetFont(&lf);
  1567. CString str;
  1568. GV_ITEM ItemTitle;
  1569. ItemTitle.mask = GVIF_TEXT | GVIF_FORMAT;
  1570. ItemTitle.nBorder = GVIS_BDR_BOTTOM;
  1571. ItemTitle.nFormat = DT_SINGLELINE | DT_VCENTER;
  1572. ItemTitle.row = 0;
  1573. ItemTitle.col = 0;
  1574. ItemTitle.nFormat |= DT_CENTER;
  1575. ItemTitle.strText = _T("序号");
  1576. m_GridCtrl.SetItem(&ItemTitle);
  1577. m_GridCtrl.MergeCells(0, 0, 1, 0);
  1578. ItemTitle.row = 0;
  1579. ItemTitle.col = 1;
  1580. ItemTitle.nFormat |= DT_CENTER;
  1581. ItemTitle.strText = _T("名称");
  1582. m_GridCtrl.SetItem(&ItemTitle);
  1583. m_GridCtrl.MergeCells(0, 1, 1, 1);
  1584. ItemTitle.row = 0;
  1585. ItemTitle.col = 2;
  1586. ItemTitle.nFormat |= DT_CENTER;
  1587. ItemTitle.strText = _T("编码");
  1588. m_GridCtrl.SetItem(&ItemTitle);
  1589. m_GridCtrl.MergeCells(0, 2, 1, 2);
  1590. ItemTitle.row = 0;
  1591. ItemTitle.col = 3;
  1592. ItemTitle.nFormat |= DT_CENTER;
  1593. ItemTitle.strText = _T("理论值");
  1594. m_GridCtrl.SetItem(&ItemTitle);
  1595. m_GridCtrl.MergeCells(0, 3, 0, 5);
  1596. ItemTitle.row = 1;
  1597. ItemTitle.col = 3;
  1598. ItemTitle.nFormat |= DT_CENTER;
  1599. ItemTitle.strText = szX;
  1600. m_GridCtrl.SetItem(&ItemTitle);
  1601. ItemTitle.row = 1;
  1602. ItemTitle.col = 4;
  1603. ItemTitle.nFormat |= DT_CENTER;
  1604. ItemTitle.strText = szY;
  1605. m_GridCtrl.SetItem(&ItemTitle);
  1606. ItemTitle.row = 1;
  1607. ItemTitle.col = 5;
  1608. ItemTitle.nFormat |= DT_CENTER;
  1609. ItemTitle.strText = szZ;
  1610. m_GridCtrl.SetItem(&ItemTitle);
  1611. ItemTitle.row = 0;
  1612. ItemTitle.col = 6;
  1613. ItemTitle.nFormat |= DT_CENTER;
  1614. str.Format(_T("实测值"));
  1615. ItemTitle.strText = str;
  1616. m_GridCtrl.SetItem(&ItemTitle);
  1617. m_GridCtrl.MergeCells(0, 6, 0, 8);
  1618. ItemTitle.row = 1;
  1619. ItemTitle.col = 6;
  1620. ItemTitle.nFormat |= DT_CENTER;
  1621. ItemTitle.strText = szX;
  1622. m_GridCtrl.SetItem(&ItemTitle);
  1623. ItemTitle.row = 1;
  1624. ItemTitle.col = 7;
  1625. ItemTitle.nFormat |= DT_CENTER;
  1626. ItemTitle.strText = szY;
  1627. m_GridCtrl.SetItem(&ItemTitle);
  1628. ItemTitle.row = 1;
  1629. ItemTitle.col = 8;
  1630. ItemTitle.nFormat |= DT_CENTER;
  1631. ItemTitle.strText = szZ;
  1632. m_GridCtrl.SetItem(&ItemTitle);
  1633. ItemTitle.row = 0;
  1634. ItemTitle.col = 9;
  1635. ItemTitle.nFormat |= DT_LEFT;
  1636. str.Format(_T("说明"));
  1637. ItemTitle.strText = str;
  1638. m_GridCtrl.SetItem(&ItemTitle);
  1639. m_GridCtrl.MergeCells(0, 9, 1, 9);
  1640. // POINT数据访问入口
  1641. EquipDataPointManager *pPointManager = m_pDoc->GetEquipDataPointManager();
  1642. ASSERT(pPointManager != NULL);
  1643. GV_ITEM Item;
  1644. Item.mask = GVIF_TEXT | GVIF_FORMAT;
  1645. Item.nFormat = DT_SINGLELINE | DT_VCENTER;
  1646. int iRow = 2;
  1647. int iIndex = 0;
  1648. CppSQLite3Query q = pPointManager->Query(m_taskId, m_szEquipCode, dwItemId, dwSubitemId);
  1649. while (!q.eof()) {
  1650. iIndex += 1;
  1651. // 序号
  1652. Item.row = iRow;
  1653. Item.col = 0;
  1654. Item.nFormat |= DT_CENTER;
  1655. str.Format("%d", iIndex);
  1656. Item.strText = str;
  1657. m_GridCtrl.SetItem(&Item);
  1658. // 名称
  1659. Item.row = iRow;
  1660. Item.col = 1;
  1661. Item.nFormat |= DT_CENTER;
  1662. str.Format("%s", q.getStringField("point_title"));
  1663. Item.strText = str;
  1664. m_GridCtrl.SetItem(&Item);
  1665. // CODE
  1666. Item.row = iRow;
  1667. Item.col = 2;
  1668. Item.nFormat |= DT_CENTER;
  1669. str.Format("%s", q.getStringField("point_code"));
  1670. Item.strText = str;
  1671. m_GridCtrl.SetItem(&Item);
  1672. /***********************************************************************************/
  1673. // 向量进行坐标系切换
  1674. DOUBLE x = q.getFloatField("point_e_x");
  1675. DOUBLE y = q.getFloatField("point_e_y");
  1676. DOUBLE z = q.getFloatField("point_e_z");
  1677. CoordCartesian ctsPoint;
  1678. ctsPoint.x = x;
  1679. ctsPoint.y = y;
  1680. ctsPoint.z = z;
  1681. if (m_iCS == 1)
  1682. {
  1683. CoordSpherical cdsPoint;
  1684. CS::CartesianToSpherical(ctsPoint, cdsPoint);
  1685. x = cdsPoint.r;
  1686. y = cdsPoint.θ;
  1687. z = cdsPoint.φ;
  1688. }
  1689. else if (m_iCS == 2)
  1690. {
  1691. CoordCylindrical ccdPoint;
  1692. CS::CartesianToCylindrical(ctsPoint, ccdPoint);
  1693. x = ccdPoint.r;
  1694. y = ccdPoint.θ;
  1695. z = ccdPoint.z;
  1696. }
  1697. // 理论 - X
  1698. Item.row = iRow;
  1699. Item.col = 3;
  1700. Item.nFormat |= DT_RIGHT;
  1701. str.Format("%.3f", x);
  1702. Item.strText = str;
  1703. m_GridCtrl.SetItem(&Item);
  1704. // 理论 - Y
  1705. Item.row = iRow;
  1706. Item.col = 4;
  1707. Item.nFormat |= DT_RIGHT;
  1708. str.Format("%.3f", y);
  1709. Item.strText = str;
  1710. m_GridCtrl.SetItem(&Item);
  1711. // 理论 - Z
  1712. Item.row = iRow;
  1713. Item.col = 5;
  1714. Item.nFormat |= DT_RIGHT;
  1715. str.Format("%.3f", z);
  1716. Item.strText = str;
  1717. m_GridCtrl.SetItem(&Item);
  1718. /**************************************************************************/
  1719. // 终点进行坐标系切换
  1720. x = q.getFloatField("point_a_x");
  1721. y = q.getFloatField("point_a_y");
  1722. z = q.getFloatField("point_a_z");
  1723. ctsPoint.x = x;
  1724. ctsPoint.y = y;
  1725. ctsPoint.z = z;
  1726. if (m_iCS == 1)
  1727. {
  1728. CoordSpherical cdsPoint;
  1729. CS::CartesianToSpherical(ctsPoint, cdsPoint);
  1730. x = cdsPoint.r;
  1731. y = cdsPoint.θ;
  1732. z = cdsPoint.φ;
  1733. }
  1734. else if (m_iCS == 2)
  1735. {
  1736. CoordCylindrical ccdPoint;
  1737. CS::CartesianToCylindrical(ctsPoint, ccdPoint);
  1738. x = ccdPoint.r;
  1739. y = ccdPoint.θ;
  1740. z = ccdPoint.z;
  1741. }
  1742. // 实测 - X
  1743. Item.row = iRow;
  1744. Item.col = 6;
  1745. Item.nFormat |= DT_RIGHT;
  1746. str.Format("%.3f", x);
  1747. Item.strText = str;
  1748. m_GridCtrl.SetItem(&Item);
  1749. // 实测 - Y
  1750. Item.row = iRow;
  1751. Item.col = 7;
  1752. Item.nFormat |= DT_RIGHT;
  1753. str.Format("%.3f", y);
  1754. Item.strText = str;
  1755. m_GridCtrl.SetItem(&Item);
  1756. // 实测 - Z
  1757. Item.row = iRow;
  1758. Item.col = 8;
  1759. Item.nFormat |= DT_RIGHT;
  1760. str.Format("%.3f", z);
  1761. Item.strText = str;
  1762. m_GridCtrl.SetItem(&Item);
  1763. /*************************************************************************/
  1764. // 说明
  1765. Item.row = iRow;
  1766. Item.col = 9;
  1767. Item.nFormat |= DT_LEFT;
  1768. str.Format("%s", q.getStringField("point_desc"));
  1769. Item.strText = str;
  1770. m_GridCtrl.SetItem(&Item);
  1771. iRow++;
  1772. q.nextRow();
  1773. }
  1774. q.finalize();
  1775. }
  1776. /**************************************************************************************************
  1777. 函 数 名 :ShowCylinderData
  1778. 功能描述 :显示数据-圆柱
  1779. 输出参数 :略
  1780. 返 回 值 :略
  1781. **************************************************************************************************/
  1782. void CStaticTask::ShowCylinderData(DWORD dwItemId, DWORD dwSubitemId)
  1783. {
  1784. TRY
  1785. {
  1786. m_GridCtrl.SetColumnCount(12);
  1787. m_GridCtrl.SetFixedRowCount(2);
  1788. m_GridCtrl.SetFixedColumnCount(1);
  1789. m_GridCtrl.SetColumnWidth(0, 40);
  1790. m_GridCtrl.SetColumnWidth(1, 120);
  1791. m_GridCtrl.SetColumnWidth(2, 120);
  1792. m_GridCtrl.SetColumnWidth(3, 100);
  1793. m_GridCtrl.SetColumnWidth(4, 100);
  1794. m_GridCtrl.SetColumnWidth(5, 100);
  1795. m_GridCtrl.SetColumnWidth(6, 100);
  1796. m_GridCtrl.SetColumnWidth(7, 100);
  1797. m_GridCtrl.SetColumnWidth(8, 120);
  1798. m_GridCtrl.SetColumnWidth(9, 120);
  1799. m_GridCtrl.SetColumnWidth(10, 120);
  1800. m_GridCtrl.SetColumnWidth(11, 120);
  1801. }
  1802. CATCH(CMemoryException, e)
  1803. {
  1804. e->ReportError();
  1805. return;
  1806. }
  1807. END_CATCH
  1808. // Get the font
  1809. CFont* pFont = m_GridCtrl.GetFont();
  1810. LOGFONT lf;
  1811. pFont->GetLogFont(&lf);
  1812. // Make it true-type
  1813. memcpy(lf.lfFaceName, _T("Arial"), 6);
  1814. // Set the fixed row defaults as this new font
  1815. m_GridCtrl.GetDefaultCell(TRUE, FALSE)->SetFont(&lf);
  1816. CString str;
  1817. GV_ITEM ItemTitle;
  1818. ItemTitle.mask = GVIF_TEXT | GVIF_FORMAT;
  1819. ItemTitle.nBorder = GVIS_BDR_BOTTOM;
  1820. ItemTitle.nFormat = DT_SINGLELINE | DT_VCENTER;
  1821. ItemTitle.row = 0;
  1822. ItemTitle.col = 0;
  1823. ItemTitle.nFormat = DT_CENTER;
  1824. ItemTitle.strText = _T("序号");
  1825. m_GridCtrl.SetItem(&ItemTitle);
  1826. m_GridCtrl.MergeCells(0, 0, 1, 0);
  1827. ItemTitle.row = 0;
  1828. ItemTitle.col = 1;
  1829. ItemTitle.nFormat = DT_CENTER;
  1830. ItemTitle.strText = _T("名称");
  1831. m_GridCtrl.SetItem(&ItemTitle);
  1832. m_GridCtrl.MergeCells(0, 1, 1, 1);
  1833. ItemTitle.row = 0;
  1834. ItemTitle.col = 2;
  1835. ItemTitle.nFormat = DT_CENTER;
  1836. ItemTitle.strText = _T("编码");
  1837. m_GridCtrl.SetItem(&ItemTitle);
  1838. m_GridCtrl.MergeCells(0, 2, 1, 2);
  1839. ItemTitle.row = 0;
  1840. ItemTitle.col = 3;
  1841. ItemTitle.nFormat = DT_CENTER;
  1842. ItemTitle.strText = _T("终点1");
  1843. m_GridCtrl.SetItem(&ItemTitle);
  1844. m_GridCtrl.MergeCells(0, 3, 0, 5);
  1845. CString szX;
  1846. CString szY;
  1847. CString szZ;
  1848. if (m_iCS == 0) {
  1849. szX.Format("%s", "X");
  1850. szY.Format("%s", "Y");
  1851. szZ.Format("%s", "Z");
  1852. }
  1853. else if (m_iCS == 1)
  1854. {
  1855. szX.Format("%s", "R");
  1856. szY.Format("%s", "θ");
  1857. szZ.Format("%s", "φ");
  1858. }
  1859. else if (m_iCS == 2)
  1860. {
  1861. szX.Format("%s", "R");
  1862. szY.Format("%s", "θ");
  1863. szZ.Format("%s", "Z");
  1864. }
  1865. ItemTitle.row = 1;
  1866. ItemTitle.col = 3;
  1867. ItemTitle.nFormat = DT_CENTER;
  1868. ItemTitle.strText = szX;
  1869. m_GridCtrl.SetItem(&ItemTitle);
  1870. ItemTitle.row = 1;
  1871. ItemTitle.col = 4;
  1872. ItemTitle.nFormat = DT_CENTER;
  1873. ItemTitle.strText = szY;
  1874. m_GridCtrl.SetItem(&ItemTitle);
  1875. ItemTitle.row = 1;
  1876. ItemTitle.col = 5;
  1877. ItemTitle.nFormat = DT_CENTER;
  1878. ItemTitle.strText = szZ;
  1879. m_GridCtrl.SetItem(&ItemTitle);
  1880. ItemTitle.row = 0;
  1881. ItemTitle.col = 6;
  1882. ItemTitle.nFormat = DT_CENTER;
  1883. ItemTitle.strText = _T("终点2");
  1884. m_GridCtrl.SetItem(&ItemTitle);
  1885. m_GridCtrl.MergeCells(0, 6, 0, 8);
  1886. ItemTitle.row = 1;
  1887. ItemTitle.col = 6;
  1888. ItemTitle.nFormat = DT_CENTER;
  1889. ItemTitle.strText = szX;
  1890. m_GridCtrl.SetItem(&ItemTitle);
  1891. ItemTitle.row = 1;
  1892. ItemTitle.col = 7;
  1893. ItemTitle.nFormat = DT_CENTER;
  1894. ItemTitle.strText = szY;
  1895. m_GridCtrl.SetItem(&ItemTitle);
  1896. ItemTitle.row = 1;
  1897. ItemTitle.col = 8;
  1898. ItemTitle.nFormat = DT_CENTER;
  1899. ItemTitle.strText = szZ;
  1900. m_GridCtrl.SetItem(&ItemTitle);
  1901. ItemTitle.row = 0;
  1902. ItemTitle.col = 9;
  1903. ItemTitle.nFormat = DT_CENTER;
  1904. ItemTitle.strText = _T("半径");
  1905. m_GridCtrl.SetItem(&ItemTitle);
  1906. m_GridCtrl.MergeCells(0, 9, 1, 9);
  1907. ItemTitle.row = 0;
  1908. ItemTitle.col = 10;
  1909. ItemTitle.nFormat = DT_CENTER;
  1910. ItemTitle.strText = _T("长度");
  1911. m_GridCtrl.SetItem(&ItemTitle);
  1912. m_GridCtrl.MergeCells(0, 10, 1, 10);
  1913. ItemTitle.row = 0;
  1914. ItemTitle.col = 11;
  1915. ItemTitle.nFormat = DT_LEFT;
  1916. ItemTitle.strText = _T("说明");
  1917. m_GridCtrl.SetItem(&ItemTitle);
  1918. m_GridCtrl.MergeCells(0, 11, 1, 11);
  1919. // Circle数据访问入口
  1920. EquipDataCylinderManager *pCylinderManager = m_pDoc->GetEquipDataCylinderManager();
  1921. ASSERT(pCylinderManager != NULL);
  1922. GV_ITEM Item;
  1923. Item.mask = GVIF_TEXT | GVIF_FORMAT;
  1924. Item.nFormat = DT_SINGLELINE | DT_VCENTER;
  1925. int iRow = 2;
  1926. int iIndex = 0;
  1927. CppSQLite3Query q = pCylinderManager->Query(m_taskId, m_szEquipCode, dwItemId, dwSubitemId);
  1928. while (!q.eof()) {
  1929. iIndex += 1;
  1930. // 序号
  1931. Item.row = iRow;
  1932. Item.col = 0;
  1933. Item.nFormat = DT_CENTER;
  1934. str.Format("%d", iIndex);
  1935. Item.strText = str;
  1936. m_GridCtrl.SetItem(&Item);
  1937. // 名称
  1938. Item.row = iRow;
  1939. Item.col = 1;
  1940. Item.nFormat = DT_CENTER;
  1941. str.Format("%s", q.getStringField("cylinder_title"));
  1942. Item.strText = str;
  1943. m_GridCtrl.SetItem(&Item);
  1944. // CODE
  1945. Item.row = iRow;
  1946. Item.col = 2;
  1947. Item.nFormat = DT_CENTER;
  1948. str.Format("%s", q.getStringField("cylinder_code"));
  1949. Item.strText = str;
  1950. m_GridCtrl.SetItem(&Item);
  1951. // 终点1作坐标系切换
  1952. DOUBLE x1 = q.getFloatField("point1_x");
  1953. DOUBLE y1 = q.getFloatField("point1_y");
  1954. DOUBLE z1 = q.getFloatField("point1_z");
  1955. DOUBLE x2 = q.getFloatField("point2_x");
  1956. DOUBLE y2 = q.getFloatField("point2_y");
  1957. DOUBLE z2 = q.getFloatField("point2_z");
  1958. CoordCartesian ctsPoint1, ctsPoint2;
  1959. ctsPoint1.x = x1;
  1960. ctsPoint1.y = y1;
  1961. ctsPoint1.z = z1;
  1962. ctsPoint2.x = x1;
  1963. ctsPoint2.y = y1;
  1964. ctsPoint2.z = z1;
  1965. if (m_iCS == 1)
  1966. {
  1967. CoordSpherical cdsPoint1, cdsPoint2;
  1968. CS::CartesianToSpherical(ctsPoint1, cdsPoint1);
  1969. x1 = cdsPoint1.r;
  1970. y1 = cdsPoint1.θ;
  1971. z1 = cdsPoint1.φ;
  1972. CS::CartesianToSpherical(ctsPoint2, cdsPoint2);
  1973. x2 = cdsPoint2.r;
  1974. y2 = cdsPoint2.θ;
  1975. z2 = cdsPoint2.φ;
  1976. }
  1977. else if (m_iCS == 2)
  1978. {
  1979. CoordCylindrical ccdPoint1, ccdPoint2;
  1980. CS::CartesianToCylindrical(ctsPoint1, ccdPoint1);
  1981. x1 = ccdPoint1.r;
  1982. y1 = ccdPoint1.θ;
  1983. z1 = ccdPoint1.z;
  1984. CS::CartesianToCylindrical(ctsPoint2, ccdPoint2);
  1985. x2 = ccdPoint2.r;
  1986. y2 = ccdPoint2.θ;
  1987. z2 = ccdPoint2.z;
  1988. }
  1989. // 终点1 - X
  1990. Item.row = iRow;
  1991. Item.col = 3;
  1992. Item.nFormat = DT_RIGHT;
  1993. str.Format("%.3f", x1);
  1994. Item.strText = str;
  1995. m_GridCtrl.SetItem(&Item);
  1996. // 终点1 - Y
  1997. Item.row = iRow;
  1998. Item.col = 4;
  1999. Item.nFormat = DT_RIGHT;
  2000. str.Format("%.3f", y1);
  2001. Item.strText = str;
  2002. m_GridCtrl.SetItem(&Item);
  2003. // 终点1 - Z
  2004. Item.row = iRow;
  2005. Item.col = 5;
  2006. Item.nFormat = DT_RIGHT;
  2007. str.Format("%.3f", z1);
  2008. Item.strText = str;
  2009. m_GridCtrl.SetItem(&Item);
  2010. // 终点2 - X
  2011. Item.row = iRow;
  2012. Item.col = 6;
  2013. Item.nFormat = DT_RIGHT;
  2014. str.Format("%.3f", x2);
  2015. Item.strText = str;
  2016. m_GridCtrl.SetItem(&Item);
  2017. // 终点2 - Y
  2018. Item.row = iRow;
  2019. Item.col = 7;
  2020. Item.nFormat = DT_RIGHT;
  2021. str.Format("%.3f", y2);
  2022. Item.strText = str;
  2023. m_GridCtrl.SetItem(&Item);
  2024. // 终点2 - Z
  2025. Item.row = iRow;
  2026. Item.col = 8;
  2027. Item.nFormat = DT_RIGHT;
  2028. str.Format("%.3f", z2);
  2029. Item.strText = str;
  2030. m_GridCtrl.SetItem(&Item);
  2031. // 半径
  2032. Item.row = iRow;
  2033. Item.col = 9;
  2034. Item.nFormat = DT_RIGHT;
  2035. str.Format("%.3f", q.getFloatField("cylinder_radius"));
  2036. Item.strText = str;
  2037. m_GridCtrl.SetItem(&Item);
  2038. // Length
  2039. Item.row = iRow;
  2040. Item.col = 10;
  2041. Item.nFormat = DT_RIGHT;
  2042. str.Format("%.3f", q.getFloatField("cylinder_length"));
  2043. Item.strText = str;
  2044. m_GridCtrl.SetItem(&Item);
  2045. // DESC
  2046. Item.row = iRow;
  2047. Item.col = 11;
  2048. Item.nFormat = DT_LEFT;
  2049. str.Format("%s", q.getStringField("cylinder_desc"));
  2050. Item.strText = str;
  2051. m_GridCtrl.SetItem(&Item);
  2052. iRow++;
  2053. q.nextRow();
  2054. }
  2055. q.finalize();
  2056. }
  2057. /**************************************************************************************************
  2058. 函 数 名 :OnBnClickedBtnCamera
  2059. 功能描述 :事件处理-相机标定
  2060. 输入参数 :无
  2061. 输出参数 :无
  2062. 返 回 值 :void
  2063. **************************************************************************************************/
  2064. void CStaticTask::OnBnClickedBtnCamera()
  2065. {
  2066. CameraConfigDlg dlg(this, m_szEquipTypeCode, m_szEquipCode);
  2067. if (dlg.DoModal() == IDOK) {
  2068. }
  2069. }
  2070. /**************************************************************************************************
  2071. 函 数 名 :OnBnClickedBtnCompare
  2072. 功能描述 :事件处理-包络比对
  2073. 输入参数 :略
  2074. 输出参数 :无
  2075. 返 回 值 :void
  2076. **************************************************************************************************/
  2077. void CStaticTask::OnBnClickedBtnCompare()
  2078. {
  2079. EnvelopeDlg dlg(this, m_taskId);
  2080. if (dlg.DoModal() == IDOK) {
  2081. }
  2082. }
  2083. /**************************************************************************************************
  2084. 函 数 名 :OnBnClickedBtnGuide
  2085. 功能描述 :事件处理-打开帮助引导对话框
  2086. 输入参数 :略
  2087. 输出参数 :无
  2088. 返 回 值 :void
  2089. **************************************************************************************************/
  2090. void CStaticTask::OnBnClickedBtnGuide()
  2091. {
  2092. CString szPath = "";
  2093. szPath.Append(Utils::GetLocalUrlDir());
  2094. szPath.Append("/Guide/");
  2095. if (m_szEquipTypeCode.IsEmpty())
  2096. {
  2097. return;
  2098. }
  2099. szPath.Append(m_szEquipTypeCode);
  2100. szPath.Append("/index.html");
  2101. BOOL bRet = Utils::IsFileExist(szPath);
  2102. if (!bRet)
  2103. {
  2104. MessageBox("系统安装目录下没有准备引导帮助文档,请联系管理员!");
  2105. return;
  2106. }
  2107. GuideDlg dlg(this, m_szEquipTypeCode);
  2108. if (dlg.DoModal() == IDOK) {
  2109. }
  2110. }
  2111. /**************************************************************************************************
  2112. 函 数 名 :OnBnClickedBtnReport
  2113. 功能描述 :事件处理-生成报告
  2114. 输出参数 :无
  2115. 返 回 值 :void
  2116. **************************************************************************************************/
  2117. void CStaticTask::OnBnClickedBtnReport()
  2118. {
  2119. StaticReport dlg(this, m_taskId);
  2120. if (dlg.DoModal() == IDOK) {
  2121. }
  2122. }
  2123. /**************************************************************************************************
  2124. 函 数 名 :OnDestroy
  2125. 功能描述 :事件处理-窗口销毁
  2126. 输出参数 :无
  2127. 返 回 值 :void
  2128. **************************************************************************************************/
  2129. void CStaticTask::OnDestroy()
  2130. {
  2131. KillTimer(MEASURE_TIMER);
  2132. CFormView::OnDestroy();
  2133. }
  2134. /**************************************************************************************************
  2135. 函 数 名 :OnSize
  2136. 功能描述 :事件处理-WMSIZE
  2137. 输出参数 :无
  2138. 返 回 值 :void
  2139. **************************************************************************************************/
  2140. void CStaticTask::OnSize(UINT nType, int cx, int cy)
  2141. {
  2142. CFormView::OnSize(nType, cx, cy);
  2143. if (m_bIsAttached)
  2144. {
  2145. RelayoutIDPMS();
  2146. }
  2147. }
  2148. /**************************************************************************************************
  2149. 函 数 名 :OnCbnSelchangeComboCs
  2150. 功能描述 :事件处理-坐标系切换
  2151. 输出参数 :无
  2152. 返 回 值 :void
  2153. **************************************************************************************************/
  2154. void CStaticTask::OnCbnSelchangeComboCS()
  2155. {
  2156. m_iCS = m_Combo_CS.GetCurSel();
  2157. if (m_iShowType == 1)
  2158. ShowPointData(m_iShowType, m_dwSubItemId);
  2159. else if (m_iShowType == 2)
  2160. ShowPlaneData(m_iShowType, m_dwSubItemId);
  2161. else if (m_iShowType == 3)
  2162. ShowCircleData(m_iShowType, m_dwSubItemId);
  2163. else if (m_iShowType == 4)
  2164. ShowLineData(m_iShowType, m_dwSubItemId);
  2165. else
  2166. ShowCylinderData(m_iShowType, m_dwSubItemId);
  2167. }
  2168. /**************************************************************************************************
  2169. 函 数 名 :OnBnClickedBtnBack
  2170. 功能描述 :事件处理-BACK
  2171. 输出参数 :无
  2172. 返 回 值 :void
  2173. **************************************************************************************************/
  2174. void CStaticTask::OnBnClickedBtnBack()
  2175. {
  2176. this->ResetFormData();
  2177. CMainFrame *pMain = (CMainFrame*)AfxGetApp()->m_pMainWnd;
  2178. ::PostMessage(pMain->m_hWnd, WM_BACK_TO_START, NULL, NULL);
  2179. }
  2180. /**************************************************************************************************
  2181. 函 数 名 :OnBnClickedBtnMesh
  2182. 功能描述 :事件处理-网形优化
  2183. 输出参数 :无
  2184. 返 回 值 :void
  2185. **************************************************************************************************/
  2186. void CStaticTask::OnBnClickedBtnIPN()
  2187. {
  2188. IPNDlg dlg(this);
  2189. if (dlg.DoModal()) {
  2190. }
  2191. }
  2192. /**************************************************************************************************
  2193. 函 数 名 :OnMeasureSuccess
  2194. 功能描述 :测量成功-WM-SUCCESS自定义消息处理
  2195. 输入参数 :略
  2196. 输出参数 :略
  2197. 返 回 值 :略
  2198. **************************************************************************************************/
  2199. LRESULT CStaticTask::OnMeasureSuccess(WPARAM wp, LPARAM lp)
  2200. {
  2201. DMSResponse *pMsg = (DMSResponse *)wp;
  2202. if (pMsg != NULL)
  2203. {
  2204. CString szMsg(pMsg->szMsg);
  2205. if (!szMsg.IsEmpty()) {
  2206. MessageBox(szMsg);
  2207. }
  2208. Utils::DMS_FreeMsg(pMsg);
  2209. }
  2210. // 更新任务为完成状态
  2211. TaskManager *pTaskManager = m_pDoc->GetTaskManager();
  2212. ASSERT(pTaskManager != NULL);
  2213. pTaskManager->UpdateStatus(m_taskId, 1); // 1表示完成状态;
  2214. // 初始化设备静态数据
  2215. InitTreeCtrlData();
  2216. // Task -> Success Status
  2217. m_iTaskStatus = 2;
  2218. // 设置UI栏位状态
  2219. ShowTaskFieldStatus();
  2220. return 0;
  2221. }
  2222. /**************************************************************************************************
  2223. 函 数 名 :OnMeasureFailure
  2224. 功能描述 :测量失败-WM-FAILURE自定义消息处理
  2225. 输入参数 :略
  2226. 输出参数 :略
  2227. 返 回 值 :略
  2228. **************************************************************************************************/
  2229. LRESULT CStaticTask::OnMeasureFailure(WPARAM wp, LPARAM lp)
  2230. {
  2231. LOG::D("StaticTask:: OnMeasureFailure");
  2232. DMSResponse *pMsg = (DMSResponse *)wp;
  2233. if (pMsg != NULL)
  2234. {
  2235. CString szMsg(pMsg->szMsg);
  2236. if (!szMsg.IsEmpty()) {
  2237. MessageBox(szMsg);
  2238. }
  2239. Utils::DMS_FreeMsg(pMsg);
  2240. }
  2241. // 设置任务为初始状态
  2242. m_iTaskStatus = 0;
  2243. // 设置UI栏位状态
  2244. ShowTaskFieldStatus();
  2245. return 0;
  2246. }
  2247. /**************************************************************************************************
  2248. 函 数 名 :OnMeasureSuccess
  2249. 功能描述 :测量成功-WM-SUCCESS自定义消息处理
  2250. 输入参数 :略
  2251. 输出参数 :略
  2252. 返 回 值 :略
  2253. **************************************************************************************************/
  2254. LRESULT CStaticTask::OnMeasureUpdateSuccess(WPARAM wp, LPARAM lp)
  2255. {
  2256. DMSResponse *pMsg = (DMSResponse *)wp;
  2257. if (pMsg != NULL)
  2258. {
  2259. CString szMsg(pMsg->szMsg);
  2260. if (!szMsg.IsEmpty()) {
  2261. MessageBox(szMsg);
  2262. }
  2263. Utils::DMS_FreeMsg(pMsg);
  2264. }
  2265. // 更新任务为完成状态
  2266. TaskManager *pTaskManager = m_pDoc->GetTaskManager();
  2267. ASSERT(pTaskManager != NULL);
  2268. pTaskManager->UpdateStatus(m_taskId, 1); // 1表示完成状态;
  2269. // 初始化设备静态数据
  2270. InitTreeCtrlData();
  2271. // Task -> Success Status
  2272. m_iTaskStatus = 2;
  2273. // 设置UI栏位状态
  2274. ShowTaskFieldStatus();
  2275. return 0;
  2276. }
  2277. /**************************************************************************************************
  2278. 函 数 名 :OnMeasureFailure
  2279. 功能描述 :测量失败-WM-FAILURE自定义消息处理
  2280. 输入参数 :略
  2281. 输出参数 :略
  2282. 返 回 值 :略
  2283. **************************************************************************************************/
  2284. LRESULT CStaticTask::OnMeasureUpdateFailure(WPARAM wp, LPARAM lp)
  2285. {
  2286. LOG::D("StaticTask:: OnMeasureUpdateFailure");
  2287. DMSResponse *pMsg = (DMSResponse *)wp;
  2288. if (pMsg != NULL)
  2289. {
  2290. CString szMsg(pMsg->szMsg);
  2291. if (!szMsg.IsEmpty()) {
  2292. MessageBox(szMsg);
  2293. }
  2294. Utils::DMS_FreeMsg(pMsg);
  2295. }
  2296. // 设置任务为初始状态
  2297. m_iTaskStatus = 2;
  2298. // 设置UI栏位状态
  2299. ShowTaskFieldStatus();
  2300. return 0;
  2301. }
  2302. /**************************************************************************************************
  2303. 函 数 名 :OnBnClickedAgv
  2304. 功能描述 :事件处理-AGV自动化测量
  2305. 输入参数 :略
  2306. 输出参数 :略
  2307. 返 回 值 :略
  2308. **************************************************************************************************/
  2309. void CStaticTask::OnBnClickedAgv()
  2310. {
  2311. /*
  2312. StaticData data(m_szEquipTypeCode, m_szEquipCode);
  2313. data.LoadDataFromFile("D:\\BDA3D2.txt");
  2314. data.PrintData();
  2315. data.SaveToDB();
  2316. data.Clear();
  2317. */
  2318. DlgTest dlg;
  2319. dlg.DoModal();
  2320. }
  2321. /**************************************************************************************************
  2322. 函 数 名 :OnTvnEndlabeleditTreeData
  2323. 功能描述 :事件处理-自动测量
  2324. 输入参数 :略
  2325. 输出参数 :无
  2326. 返 回 值 :void
  2327. **************************************************************************************************/
  2328. void CStaticTask::OnBnClickedBtnAuto()
  2329. {
  2330. CString szResult;
  2331. // 从IDPMS获取数据
  2332. IDPMSManager *pManager = IDPMSManager::GetManager();
  2333. // 启动IDPMS多线程模式
  2334. BOOL bRet = pManager->StartStaticProcThread(this, m_taskId, m_szEquipTypeCode, m_szEquipCode);
  2335. if (!bRet)
  2336. {
  2337. MessageBox("从IDPMS获取数据失败!");
  2338. return;
  2339. }
  2340. // 设置任务为运行状态
  2341. m_iTaskStatus = 1;
  2342. // 设置UI栏位状态
  2343. ShowTaskFieldStatus();
  2344. }
  2345. /**************************************************************************************************
  2346. 函 数 名 :OnTvnEndlabeleditTreeData
  2347. 功能描述 :事件处理-自动测量
  2348. 输入参数 :略
  2349. 输出参数 :无
  2350. 返 回 值 :void
  2351. **************************************************************************************************/
  2352. void CStaticTask::OnBnClickedBtnUpdate()
  2353. {
  2354. CString szResult;
  2355. // 从IDPMS获取数据
  2356. IDPMSManager *pManager = IDPMSManager::GetManager();
  2357. // 启动IDPMS多线程模式
  2358. BOOL bRet = pManager->StartStaticDataProcThread(this, m_taskId, m_szEquipTypeCode, m_szEquipCode);
  2359. if (!bRet)
  2360. {
  2361. MessageBox("更新失败!");
  2362. return;
  2363. }
  2364. // 设置任务为运行状态
  2365. m_iTaskStatus = 1;
  2366. m_Btn_Update.SetWindowText("处理中...");
  2367. // 设置UI栏位状态
  2368. ShowTaskFieldStatus();
  2369. }
  2370. /**************************************************************************************************
  2371. 函 数 名 :OnBnClickedMbtnStaticCamera
  2372. 功能描述 :相机标定菜单事件处理
  2373. 输入参数 :略
  2374. 输出参数 :略
  2375. 返 回 值 :略
  2376. **************************************************************************************************/
  2377. void CStaticTask::OnBnClickedMbtnStaticCamera()
  2378. {
  2379. int iOpt = m_MBtn_Cam.m_nMenuResult;
  2380. int iCam = 1;
  2381. if (iOpt == IDM_CAM_1) iCam = 1;
  2382. else iCam = 2;
  2383. // 启动IDPMS多线程模式
  2384. IDPMSManager *pManager = IDPMSManager::GetManager();
  2385. BOOL bRet = pManager->SingleCameraConfigProcThread(this, iCam);
  2386. return;
  2387. }
  2388. /**************************************************************************************************
  2389. 函 数 名 :OnCamConfigSuccess
  2390. 功能描述 :WM_CAM_COFNIG_SUCCESS相机标定成功处理
  2391. 输入参数 :略
  2392. 输出参数 :略
  2393. 返 回 值 :略
  2394. **************************************************************************************************/
  2395. afx_msg LRESULT CStaticTask::OnCamConfigSuccess(WPARAM wp, LPARAM lp)
  2396. {
  2397. DMSResponse *pMsg = (DMSResponse *)wp;
  2398. CString szMsg;
  2399. if (pMsg != NULL)
  2400. {
  2401. szMsg.Format("%s", pMsg->szMsg);
  2402. CameraInfo dlg(this, szMsg);
  2403. dlg.DoModal();
  2404. Utils::DMS_FreeMsg(pMsg);
  2405. }
  2406. else
  2407. {
  2408. szMsg.Format("%s", _T("执行成功!"));
  2409. MessageBox(szMsg);
  2410. }
  2411. return 0;
  2412. }
  2413. /**************************************************************************************************
  2414. 函 数 名 :OnCamConfigFailure
  2415. 功能描述 :WM_CAM_COFNIG_FAILURE相机标定失败处理
  2416. 输入参数 :略
  2417. 输出参数 :略
  2418. 返 回 值 :略
  2419. **************************************************************************************************/
  2420. afx_msg LRESULT CStaticTask::OnCamConfigFailure(WPARAM wp, LPARAM lp)
  2421. {
  2422. DMSResponse *pMsg = (DMSResponse *)wp;
  2423. CString szMsg;
  2424. if (pMsg != NULL)
  2425. {
  2426. szMsg.Format("%s", pMsg->szMsg);
  2427. Utils::DMS_FreeMsg(pMsg);
  2428. }
  2429. else
  2430. {
  2431. szMsg.Format("%s", _T("执行失败!"));
  2432. }
  2433. MessageBox(szMsg);
  2434. return 0;
  2435. }
  2436. /**************************************************************************************************
  2437. 函 数 名 :OnRestartIDPMS
  2438. 功能描述 :WM_RESTART_IDPMS处理
  2439. 输入参数 :略
  2440. 输出参数 :略
  2441. 返 回 值 :略
  2442. **************************************************************************************************/
  2443. afx_msg LRESULT CStaticTask::OnReStartIDPMS(WPARAM wp, LPARAM lp)
  2444. {
  2445. LOG::D("StaticTask:: OnReStartIDPMS");
  2446. // 从IDPMS获取数据
  2447. IDPMSManager *pManager = IDPMSManager::GetManager();
  2448. BOOL bRet = pManager->StartIDPMS2();
  2449. if (bRet)
  2450. {
  2451. AttachIDPMS();
  2452. RelayoutIDPMS();
  2453. // 设置任务为运行状态
  2454. m_iTaskStatus = 0;
  2455. // 设置UI栏位状态
  2456. ShowTaskFieldStatus();
  2457. }
  2458. return 0;
  2459. }
  2460. /**************************************************************************************************
  2461. 函 数 名 :OnTimer
  2462. 功能描述 :定时器消息
  2463. 输入参数 :略
  2464. 输出参数 :略
  2465. 返 回 值 :略
  2466. **************************************************************************************************/
  2467. void CStaticTask::OnTimer(UINT_PTR nIDEvent)
  2468. {
  2469. switch (nIDEvent) {
  2470. case MEASURE_TIMER:
  2471. ::InvalidateRect(g_hIDPMSHWnd, NULL, TRUE);
  2472. ::UpdateWindow(g_hIDPMSHWnd);
  2473. break;
  2474. }
  2475. CFormView::OnTimer(nIDEvent);
  2476. }