Old fashion design for PC-104
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

253 lines
6.2 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 13/04/2001
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: MapZoomDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of MapZoomDlg.cpp
  13. //----------------------------------------------------------------------------
  14. // MapZoomDlg.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "chicago.h"
  18. #include "MapZoomDlg.h"
  19. #include "..\DLIB\AuxLib.h"
  20. #include "..\DLIB\Version.h"
  21. #ifdef _DEBUG
  22. #define new DEBUG_NEW
  23. #undef THIS_FILE
  24. static char THIS_FILE[] = __FILE__;
  25. #endif
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CMapZoomDlg dialog
  28. CMapZoomDlg::CMapZoomDlg(CWnd* pParent /*=NULL*/)
  29. : CDialog(CMapZoomDlg::IDD, pParent)
  30. {
  31. //{{AFX_DATA_INIT(CMapZoomDlg)
  32. // NOTE: the ClassWizard will add member initialization here
  33. //}}AFX_DATA_INIT
  34. m_pMapSite = NULL;
  35. m_pCurrentSensor = NULL;
  36. }
  37. void CMapZoomDlg::DoDataExchange(CDataExchange* pDX)
  38. {
  39. CDialog::DoDataExchange(pDX);
  40. //{{AFX_DATA_MAP(CMapZoomDlg)
  41. DDX_Control(pDX, IDC_BUTTON_NEXT, m_ButtonNext);
  42. DDX_Control(pDX, IDC_BUTTON_PREV, m_ButtonPrev);
  43. //}}AFX_DATA_MAP
  44. }
  45. BEGIN_MESSAGE_MAP(CMapZoomDlg, CDialog)
  46. //{{AFX_MSG_MAP(CMapZoomDlg)
  47. ON_WM_MOVING()
  48. ON_WM_SIZE()
  49. ON_WM_SIZING()
  50. ON_WM_TIMER()
  51. ON_BN_CLICKED(IDC_BUTTON_PREV, OnButtonPrev)
  52. ON_MESSAGE( WM_SENSOR_UPDATE, OnWMSensorUpdate )
  53. ON_MESSAGE( WM_ENABLE_SENSOR, OnWMEnableSensor )
  54. ON_BN_CLICKED(IDC_BUTTON_NEXT, OnButtonNext)
  55. //}}AFX_MSG_MAP
  56. ON_MESSAGE( WM_SENSOR_SHOW, OnWMSensorCurrent )
  57. END_MESSAGE_MAP()
  58. /////////////////////////////////////////////////////////////////////////////
  59. // CMapZoomDlg message handlers
  60. void CMapZoomDlg::OnMoving(UINT fwSide, LPRECT pRect)
  61. {
  62. CRect rect;
  63. GetParent()->GetClientRect( &rect );
  64. GetParent()->ClientToScreen( &rect );
  65. if( pRect->left < rect.left )
  66. {
  67. pRect->right += rect.left - pRect->left;
  68. pRect->left = rect.left;
  69. }
  70. if( pRect->top < rect.top )
  71. {
  72. pRect->bottom += rect.top - pRect->top;
  73. pRect->top = rect.top;
  74. }
  75. if( pRect->right > rect.right )
  76. {
  77. pRect->left -= pRect->right - rect.right;
  78. pRect->right = rect.right;
  79. }
  80. if( pRect->bottom > rect.bottom )
  81. {
  82. pRect->top -= pRect->bottom - rect.bottom;
  83. pRect->bottom = rect.bottom;
  84. }
  85. CDialog::OnMoving( fwSide, pRect );
  86. }
  87. void CMapZoomDlg::SetMapData( CMapData *pMapData )
  88. {
  89. m_pMapSite->SetMapData( pMapData );
  90. }
  91. BOOL CMapZoomDlg::OnInitDialog()
  92. {
  93. CDialog::OnInitDialog();
  94. RECT rect;
  95. GetClientRect( &rect );
  96. m_pMapSite = new CMapWnd();
  97. m_pMapSite->Create( NULL, NULL, WS_CHILD, rect, this, 0UL );
  98. m_pMapSite->BigImage() = TRUE;
  99. m_pMapSite->ShowWindow( SW_SHOW );
  100. // m_pMapSite->UpdateWindow();
  101. if( m_nRunningMode != MODE_MOBILEMAP )
  102. {
  103. m_ButtonPrev.ShowWindow( SW_HIDE );
  104. m_ButtonNext.ShowWindow( SW_HIDE );
  105. }
  106. return TRUE; // return TRUE unless you set the focus to a control
  107. // EXCEPTION: OCX Property Pages should return FALSE
  108. }
  109. BOOL CMapZoomDlg::DestroyWindow()
  110. {
  111. delete m_pMapSite;
  112. return CDialog::DestroyWindow();
  113. }
  114. void CMapZoomDlg::SetMapCenterAndScale( SDPOINT& point, double scale )
  115. {
  116. CRect viewRect;
  117. GetClientRect( &viewRect );
  118. SDPOINT dp = CalcViewCenterShift( viewRect, m_pMapSite->GetMapData()->GetMapSize(), scale );
  119. SDPOINT res( point.x - dp.x, point.y - dp.y );
  120. m_pMapSite->SetMapShiftScale( res, scale );
  121. // m_pMapSite->InvalidateRect( NULL );
  122. // m_pMapSite->UpdateWindow();
  123. }
  124. LRESULT CMapZoomDlg::OnWMSensorCurrent( WPARAM wParam, LPARAM lParam )
  125. {
  126. if( m_nRunningMode != MODE_MOBILEMAP )
  127. {
  128. GetParent()->SendMessage( WM_SENSOR_SHOW, wParam, lParam );
  129. m_pCurrentSensor = (CSensor*)wParam;
  130. m_pMapSite->SetActive( m_pCurrentSensor );
  131. }
  132. return 0UL;
  133. }
  134. void CMapZoomDlg::OnSize(UINT nType, int cx, int cy)
  135. {
  136. CDialog::OnSize(nType, cx, cy);
  137. CRect rect;
  138. GetClientRect( &rect );
  139. if( m_pMapSite )
  140. m_pMapSite->MoveWindow( rect );
  141. }
  142. LRESULT CMapZoomDlg::OnWMSensorUpdate(WPARAM wParam, LPARAM lParam)
  143. {
  144. return m_pMapSite->SendMessage( WM_SENSOR_UPDATE, wParam, lParam );
  145. }
  146. void CMapZoomDlg::OnSizing(UINT fwSide, LPRECT pRect)
  147. {
  148. CRect rect;
  149. GetParent()->GetClientRect( &rect );
  150. GetParent()->ClientToScreen( &rect );
  151. if( pRect->left < rect.left ) pRect->left = rect.left;
  152. if( pRect->right > rect.right ) pRect->right = rect.right;
  153. if( pRect->top < rect.top ) pRect->top = rect.top;
  154. if( pRect->bottom > rect.bottom ) pRect->bottom = rect.bottom;
  155. CDialog::OnSizing( fwSide, pRect );
  156. }
  157. void CMapZoomDlg::OnTimer(UINT nIDEvent)
  158. {
  159. m_pMapSite->SendMessage( WM_TIMER, nIDEvent );
  160. m_ButtonPrev.Invalidate();
  161. m_ButtonNext.Invalidate();
  162. CDialog::OnTimer(nIDEvent);
  163. }
  164. LRESULT CMapZoomDlg::OnWMEnableSensor(WPARAM wParam, LPARAM lParam)
  165. {
  166. return GetParent()->SendMessage( WM_ENABLE_SENSOR, wParam, lParam );
  167. }
  168. double CMapZoomDlg::GetMapScale()
  169. {
  170. return m_pMapSite->GetMapScale();
  171. }
  172. void CMapZoomDlg::SetMapScale( double scale )
  173. {
  174. SDPOINT shift = m_pMapSite->GetMapShift();
  175. m_pMapSite->SetMapShiftScale( shift, scale );
  176. }
  177. void CMapZoomDlg::OnButtonPrev()
  178. {
  179. if( m_pCurrentSensor != 0 )
  180. {
  181. int nIndex = m_pCurrentSensor->GetArrayIndex();
  182. if( nIndex > 0 )
  183. {
  184. CSensor *pSensor = m_pSensorArray->GetSensor( nIndex-1 );
  185. GetParent()->SendMessage( WM_SENSOR_SHOW, (WPARAM)pSensor, (LPARAM)(pSensor) );
  186. }
  187. }
  188. }
  189. void CMapZoomDlg::SetSensorArray(CSensorArray *pSensorArray)
  190. {
  191. m_pSensorArray = pSensorArray;
  192. }
  193. void CMapZoomDlg::SetCurrentSensor(CSensor *pSensor)
  194. {
  195. m_pCurrentSensor = pSensor;
  196. if( m_pMapSite )
  197. m_pMapSite->SetActive( m_pCurrentSensor );
  198. }
  199. void CMapZoomDlg::OnButtonNext()
  200. {
  201. if( m_pCurrentSensor != 0 )
  202. {
  203. int nIndex = m_pCurrentSensor->GetArrayIndex();
  204. if( nIndex < m_pSensorArray->GetSensorCount()-1 )
  205. {
  206. CSensor *pSensor = m_pSensorArray->GetSensor( nIndex+1 );
  207. GetParent()->SendMessage( WM_SENSOR_SHOW, (WPARAM)pSensor, (LPARAM)(pSensor) );
  208. }
  209. }
  210. }
  211. void CMapZoomDlg::SetRunningMode(int nMode)
  212. {
  213. m_nRunningMode = nMode;
  214. }