SearchSignDlg.cpp
上传用户:yffx2008
上传日期:2014-10-12
资源大小:12414k
文件大小:9k
源码类别:

交通/航空行业

开发平台:

Visual C++

  1. // SearchSignDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "GpsSC.h"
  5. #include "SearchSignDlg.h"
  6. #include "GpsSignObject.h"
  7. #include "GpsAreaLibStruct.h"
  8. #include "GpsFatStruct.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CSearchSignDlg dialog
  16. // const BYTE AreaLibLevelTotal = 4;
  17. CSearchSignDlg::CSearchSignDlg(CWnd* pParent /*=NULL*/)
  18. : CDialog(CSearchSignDlg::IDD, pParent)
  19. {
  20. //{{AFX_DATA_INIT(CSearchSignDlg)
  21. m_sAdvertiseInfo = _T("没有信息");
  22. //}}AFX_DATA_INIT
  23. }
  24. CSearchSignDlg::CSearchSignDlg(CObList *SignList,CObList *AreaList,CWnd* pParent /*=NULL*/)
  25. : CDialog(CSearchSignDlg::IDD, pParent)
  26. {
  27. lSignList = SignList;
  28. lAreaList = AreaList;
  29. }
  30. void CSearchSignDlg::DoDataExchange(CDataExchange* pDX)
  31. {
  32. CDialog::DoDataExchange(pDX);
  33. //{{AFX_DATA_MAP(CSearchSignDlg)
  34. DDX_Control(pDX, IDC_AREA_TREE, m_ctlAreaTree);
  35. DDX_Control(pDX, IDC_OTHER_AREA, m_ctlOtherArea);
  36. DDX_Control(pDX, IDC_ADVERTISE_INFO, m_ctlAdvertiseInfo);
  37. DDX_Control(pDX, IDC_CAPTION, m_ctlCaption);
  38. DDX_Control(pDX, IDC_SIGN_TYPE, m_ctlSignType);
  39. DDX_Control(pDX, IDC_SIGN_LIST, m_ctlSignList);
  40. DDX_Control(pDX, IDC_SEARCH, m_btnSearch);
  41. DDX_Control(pDX, IDC_CURR_AREA, m_ctlCurrArea);
  42. DDX_Text(pDX, IDC_ADVERTISE_INFO, m_sAdvertiseInfo);
  43. //}}AFX_DATA_MAP
  44. }
  45. BEGIN_MESSAGE_MAP(CSearchSignDlg, CDialog)
  46. //{{AFX_MSG_MAP(CSearchSignDlg)
  47. ON_BN_CLICKED(IDC_SEARCH, OnSearch)
  48. ON_BN_CLICKED(IDC_CURR_AREA, OnCurrArea)
  49. ON_CBN_SELCHANGE(IDC_SIGN_TYPE, OnSelchangeSignType)
  50. ON_BN_CLICKED(IDC_OTHER_AREA, OnOtherArea)
  51. ON_NOTIFY(NM_DBLCLK, IDC_AREA_TREE, OnDblclkAreaTree)
  52. ON_NOTIFY(TVN_SELCHANGED, IDC_AREA_TREE, OnSelchangedAreaTree)
  53. ON_WM_DESTROY()
  54. ON_LBN_DBLCLK(IDC_SIGN_LIST, OnDblclkSignList)
  55. //}}AFX_MSG_MAP
  56. END_MESSAGE_MAP()
  57. /////////////////////////////////////////////////////////////////////////////
  58. // CSearchSignDlg message handlers
  59. BOOL CSearchSignDlg::OnInitDialog() 
  60. {
  61. CDialog::OnInitDialog();
  62. // TODO: Add extra initialization here
  63. m_sAdvertiseInfo.Empty();
  64. m_ctlSignType.SetCurSel(0);
  65. m_ctlCurrArea.SetCheck(1);
  66. m_ctlAreaTree.ShowWindow(FALSE);
  67. OnSelchangeSignType();
  68. ListTypeAreaLib(lAreaList);
  69. return TRUE;  // return TRUE unless you set the focus to a control
  70.               // EXCEPTION: OCX Property Pages should return FALSE
  71. }
  72. void CSearchSignDlg::OnSearch() 
  73. {
  74. // TODO: Add your control notification handler code here
  75. }
  76. void CSearchSignDlg::OnCurrArea() 
  77. {
  78. // TODO: Add your control notification handler code here
  79. if(m_ctlCurrArea.GetCheck()) {
  80. m_ctlCaption.ShowWindow(TRUE);
  81. m_ctlCaption.EnableWindow(TRUE);
  82. m_ctlAdvertiseInfo.EnableWindow(TRUE);
  83. m_ctlAdvertiseInfo.ShowWindow(TRUE);
  84. m_ctlAreaTree.ShowWindow(FALSE);
  85. m_ctlAreaTree.EnableWindow(FALSE);
  86. ListTypeSignLib(lSignList);
  87. }
  88. else {
  89. m_ctlCaption.ShowWindow(FALSE);
  90. m_ctlCaption.EnableWindow(FALSE);
  91. m_ctlAdvertiseInfo.EnableWindow(FALSE);
  92. m_ctlAdvertiseInfo.ShowWindow(FALSE);
  93. m_ctlAreaTree.ShowWindow(TRUE);
  94. m_ctlAreaTree.EnableWindow(TRUE);
  95. // m_ctlSignList.ShowWindow(FALSE);
  96. }
  97. }
  98. void CSearchSignDlg::OnOtherArea() 
  99. {
  100. // TODO: Add your control notification handler code here
  101. if(m_ctlOtherArea.GetCheck()) {
  102. m_ctlCaption.ShowWindow(FALSE);
  103. m_ctlCaption.EnableWindow(FALSE);
  104. m_ctlAdvertiseInfo.EnableWindow(FALSE);
  105. m_ctlAdvertiseInfo.ShowWindow(FALSE);
  106. m_ctlAreaTree.ShowWindow(TRUE);
  107. m_ctlAreaTree.EnableWindow(TRUE);
  108. ListTypeSignLib(&lOtherSignList);
  109. // m_ctlSignList.ShowWindow(FALSE);
  110. }
  111. else {
  112. m_ctlCaption.ShowWindow(TRUE);
  113. m_ctlCaption.EnableWindow(TRUE);
  114. m_ctlAdvertiseInfo.EnableWindow(TRUE);
  115. m_ctlAdvertiseInfo.ShowWindow(TRUE);
  116. m_ctlAreaTree.ShowWindow(FALSE);
  117. m_ctlAreaTree.EnableWindow(FALSE);
  118. // m_ctlSignList.ShowWindow(TRUE);
  119. }
  120. }
  121. void CSearchSignDlg::ListTypeSignLib(CObList *SignList)
  122. {
  123. CGpsSignObject *pSign;
  124. POSITION pos;
  125. CString SignName;
  126. BYTE SignType;
  127. UpdateData(TRUE);
  128. SignType = m_ctlSignType.GetCurSel();
  129. m_ctlSignList.ResetContent();
  130. pos = SignList->GetTailPosition();
  131. while(pos != NULL) {
  132. pSign  = (CGpsSignObject*)SignList->GetPrev(pos);
  133. SignName = pSign->m_pSignObjectName;
  134. if(SignName.IsEmpty()) continue;
  135. if((SignType != 0) && (pSign->m_bySignType != SignType)) continue;
  136. m_ctlSignList.AddString(pSign->m_pSignObjectName);
  137. }
  138. }
  139. void CSearchSignDlg::ListTypeAreaLib(CObList *AreaList)
  140. {
  141. CGpsAreaLibStruct *pArea;
  142. POSITION pos;
  143. TVINSERTSTRUCT tvInsert;
  144. HTREEITEM hParent;
  145. BYTE i;
  146. for(i = 1; i <= AreaLibLevelTotal; i++) {
  147. pos = AreaList->GetTailPosition();
  148. while(pos != NULL) {
  149. pArea  = (CGpsAreaLibStruct*)AreaList->GetPrev(pos);
  150. if(pArea->m_byAreaLevel != i) continue;
  151. if(i == 1) {
  152. tvInsert.hParent = NULL;
  153. tvInsert.hInsertAfter = NULL;
  154. tvInsert.item.mask = TVIF_TEXT;
  155. tvInsert.item.pszText = _T(pArea->m_arrAreaName);
  156. hParent = m_ctlAreaTree.InsertItem(&tvInsert);
  157. CString str;
  158. str = pArea->m_arrAreaABCD;
  159. str = str.Left(i * 2);
  160. AddSubAreaToTree(hParent,AreaList,i,str);
  161. break;
  162. }
  163. }
  164. }
  165. }
  166. void CSearchSignDlg::AddSubAreaToTree(HTREEITEM hParent,CObList *AreaList,BYTE i,CString Level)
  167. {
  168. CGpsAreaLibStruct *pArea;
  169. POSITION pos;
  170. CString Name;
  171. HTREEITEM hCurrent;
  172. pos = AreaList->GetTailPosition();
  173. while(pos != NULL) {
  174. pArea  = (CGpsAreaLibStruct*)AreaList->GetPrev(pos);
  175. Name = pArea->m_arrAreaABCD;
  176. Name = Name.Left(i * 2);
  177. if(pArea->m_byAreaLevel != i + 1) continue;
  178. if(Level != Name) continue;
  179. hCurrent = m_ctlAreaTree.InsertItem(_T(pArea->m_arrAreaName),hParent,NULL);
  180. if(i < AreaLibLevelTotal - 1) {
  181. Name = pArea->m_arrAreaABCD;
  182. Name = Name.Left((i + 1) * 2);
  183. AddSubAreaToTree(hCurrent,AreaList,i + 1,Name);
  184. }
  185. }
  186. }
  187. void CSearchSignDlg::OnSelchangeSignType() 
  188. {
  189. // TODO: Add your control notification handler code here
  190. if(m_ctlCurrArea.GetCheck()) {
  191. ListTypeSignLib(lSignList);
  192. }
  193. else {
  194. ListTypeSignLib(&lOtherSignList);
  195. }
  196. }
  197. void CSearchSignDlg::OnSelchangedAreaTree(NMHDR* pNMHDR, LRESULT* pResult) 
  198. {
  199. NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
  200. // TODO: Add your control notification handler code here
  201. m_hCurrTree = m_ctlAreaTree.GetSelectedItem();
  202. *pResult = 0;
  203. }
  204. void CSearchSignDlg::OnDblclkAreaTree(NMHDR* pNMHDR, LRESULT* pResult) 
  205. {
  206. // TODO: Add your control notification handler code here
  207. CGpsAreaLibStruct *pArea = NULL;
  208. POSITION pos;
  209. CString Name,SignName;
  210. SignName = m_ctlAreaTree.GetItemText(m_hCurrTree);
  211. pos = lAreaList->GetTailPosition();
  212. while(pos != NULL) {
  213. pArea = (CGpsAreaLibStruct*)lAreaList->GetPrev(pos);
  214. if(pArea->m_byAreaLevel != AreaLibLevelTotal) continue;
  215. Name = pArea->m_arrAreaName;
  216. if(SignName != Name) continue;
  217. ClearSignList(&lOtherSignList);
  218. m_pDrawMap->GetSignLib(pArea->m_arrRelateSignLibName,&lOtherSignList,false);
  219. ListTypeSignLib(&lOtherSignList);
  220. }
  221. *pResult = 0;
  222. }
  223. void CSearchSignDlg::GetParent(CGpsDrawMap *pDrawMap)
  224. {
  225. m_pDrawMap = pDrawMap;
  226. }
  227. void CSearchSignDlg::ClearSignList(CObList *SignList)
  228. {
  229. CGpsSignObject *pSign = NULL;
  230. POSITION pos;
  231. pos = SignList->GetTailPosition();
  232. while(pos != NULL) {
  233. pSign = (CGpsSignObject*)SignList->GetPrev(pos);
  234. delete pSign;
  235. }
  236. SignList->RemoveAll();
  237. }
  238. void CSearchSignDlg::OnDestroy() 
  239. {
  240. CDialog::OnDestroy();
  241. // TODO: Add your message handler code here
  242. ClearSignList(&lOtherSignList);
  243. }
  244. void CSearchSignDlg::OnDblclkSignList() 
  245. {
  246. // TODO: Add your control notification handler code here
  247. CGpsSignObject *pSign = NULL;
  248. POSITION pos;
  249. CString SignName,Name;
  250. bool Flag = false;
  251. m_ctlSignList.GetText(m_ctlSignList.GetCurSel(),SignName);
  252. if(SignName.IsEmpty()) return;
  253. if(m_ctlCurrArea.GetCheck()) {
  254. pos = lSignList->GetTailPosition();
  255. while(pos != NULL) {
  256. pSign = (CGpsSignObject*)lSignList->GetPrev(pos);
  257. Name  = pSign->m_pSignObjectName;
  258. if(Name != SignName) continue;
  259. Flag = true;
  260. break;
  261. }
  262. }
  263. if(m_ctlOtherArea.GetCheck()) {
  264. pos = lOtherSignList.GetTailPosition();
  265. while(pos != NULL) {
  266. pSign = (CGpsSignObject*)lOtherSignList.GetPrev(pos);
  267. Name  = pSign->m_pSignObjectName;
  268. if(Name != SignName) continue;
  269. Flag = true;
  270. break;
  271. }
  272. }
  273. if(!Flag) return;
  274. m_pDrawMap->CheckMapIsChange(pSign->m_dgx,pSign->m_dgy);
  275. m_pDrawMap->RefreshMapWnd();
  276. m_pDrawMap->CovertNEXY(pSign, m_pDrawMap->m_cCurrMapInfo.CoeffNE_XY, true);
  277. m_pDrawMap->pDispOneSign.m_lx = pSign->m_lx;
  278. m_pDrawMap->pDispOneSign.m_ly = pSign->m_ly;
  279. m_pDrawMap->pDispOneSign.m_sIconName = pSign->m_sIconName;
  280. m_pDrawMap->CopyEquaLenArr(pSign->m_pSignObjectName,m_pDrawMap->pDispOneSign.m_pSignObjectName,pSign->m_bySignName_Bytes);
  281. m_pDrawMap->FreshWnd();
  282. }