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.

208 lines
7.1 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 10/04/2001
  5. // Last modification: 08/10/2003
  6. // Project Intruder Position Indicator
  7. // SUBSYSTEM: Camera calibration dialog
  8. // FILE: CalibDlg.cpp
  9. // AUTHOR: Belkovsky Joseph
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source of implementation of the Camera calibration dialog
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "..\LgLib\Version.h"
  16. #include "CalibDlg.h"
  17. #include "Profile.h"
  18. static WNDPROC lpfnOldWndProc;// Old Window Procedure for class "edit"
  19. LRESULT CALLBACK NewEditProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  20. {
  21. switch(message)
  22. {
  23. case WM_CHAR:
  24. if(isdigit(wParam) || wParam == '.' || wParam == '-' ||
  25. wParam == 0x08 || wParam == '+' || toupper(wParam) == 'E')
  26. CallWindowProc(lpfnOldWndProc, hWnd, message, wParam, lParam);
  27. return 0L;
  28. default:
  29. break;
  30. }
  31. return CallWindowProc(lpfnOldWndProc, hWnd, message, wParam, lParam);
  32. }
  33. BOOL CALLBACK CalibDlgProc(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
  34. {
  35. static CProfile* pProfile;
  36. static BOOL fEnable;
  37. double result;
  38. WORD wIdc;
  39. char buffer[0x500];
  40. switch(msg)
  41. {
  42. case WM_INITDIALOG:
  43. pProfile = (CProfile*)lParam;
  44. fEnable = FALSE;
  45. SetDlgItemText(hdlg, IDC_STATIC_STATE_ERROR,
  46. "To write information, enter password");
  47. _sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_master_Xc() );
  48. SetDlgItemText(hdlg, IDC_EDIT_MASTER_XC, buffer);
  49. _sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_master_Yc() );
  50. SetDlgItemText(hdlg, IDC_EDIT_MASTER_YC, buffer );
  51. _sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_master_Zc() );
  52. SetDlgItemText(hdlg, IDC_EDIT_MASTER_ZC, buffer );
  53. _sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_master_Psi() );
  54. SetDlgItemText(hdlg, IDC_EDIT_MASTER_PSI, buffer );
  55. _sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_master_Theta() );
  56. SetDlgItemText(hdlg, IDC_EDIT_MASTER_THETA, buffer );
  57. _sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_master_Phi() );
  58. SetDlgItemText(hdlg, IDC_EDIT_MASTER_PHI, buffer );
  59. _sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_slave_Xc() );
  60. SetDlgItemText(hdlg, IDC_EDIT_SLAVE_XC, buffer);
  61. _sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_slave_Yc() );
  62. SetDlgItemText(hdlg, IDC_EDIT_SLAVE_YC, buffer );
  63. _sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_slave_Zc() );
  64. SetDlgItemText(hdlg, IDC_EDIT_SLAVE_ZC, buffer );
  65. _sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_slave_Psi() );
  66. SetDlgItemText(hdlg, IDC_EDIT_SLAVE_PSI, buffer );
  67. _sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_slave_Theta() );
  68. SetDlgItemText(hdlg, IDC_EDIT_SLAVE_THETA, buffer );
  69. _sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_slave_Phi() );
  70. SetDlgItemText(hdlg, IDC_EDIT_SLAVE_PHI, buffer );
  71. // Set read only for alls edit control
  72. for(wIdc = IDC_EDIT_MASTER_XC; wIdc <= IDC_EDIT_SLAVE_PHI; ++wIdc)
  73. {
  74. SendMessage(GetDlgItem(hdlg, wIdc), EM_SETREADONLY,
  75. (WPARAM)TRUE, (LPARAM)0L);
  76. }
  77. // Change Window procedure for alls edit control
  78. lpfnOldWndProc = (WNDPROC)GetWindowLong(GetDlgItem(hdlg, IDC_EDIT_MASTER_XC),
  79. GWL_WNDPROC);
  80. for(wIdc = IDC_EDIT_MASTER_XC; wIdc <= IDC_EDIT_SLAVE_PHI; ++wIdc)
  81. SetWindowLong(GetDlgItem(hdlg, wIdc), GWL_WNDPROC,
  82. (LONG)NewEditProc);
  83. return TRUE;
  84. case WM_COMMAND:
  85. switch(LOWORD(wParam))
  86. {
  87. case IDOK:
  88. if(!fEnable)
  89. goto LabelNoPassword;
  90. if(GetDlgItemText(hdlg, IDC_EDIT_MASTER_XC, buffer, sizeof(buffer)) &&
  91. sscanf(buffer, "%lf", &result) == 1)
  92. pProfile->get_master_Xc() = result;
  93. if(GetDlgItemText(hdlg, IDC_EDIT_MASTER_YC, buffer, sizeof(buffer)) &&
  94. sscanf(buffer, "%lf", &result) == 1)
  95. pProfile->get_master_Yc() = result;
  96. if(GetDlgItemText(hdlg, IDC_EDIT_MASTER_ZC, buffer, sizeof(buffer)) &&
  97. sscanf(buffer, "%lf", &result) == 1)
  98. pProfile->get_master_Zc() = result;
  99. if(GetDlgItemText(hdlg, IDC_EDIT_MASTER_PSI, buffer, sizeof(buffer)) &&
  100. sscanf(buffer, "%lf", &result) == 1)
  101. pProfile->get_master_Psi() = result;
  102. if(GetDlgItemText(hdlg, IDC_EDIT_MASTER_THETA, buffer, sizeof(buffer)) &&
  103. sscanf(buffer, "%lf", &result) == 1)
  104. pProfile->get_master_Theta() = result;
  105. if(GetDlgItemText(hdlg, IDC_EDIT_MASTER_PHI, buffer, sizeof(buffer)) &&
  106. sscanf(buffer, "%lf", &result) == 1)
  107. pProfile->get_master_Phi() = result;
  108. if(GetDlgItemText(hdlg, IDC_EDIT_SLAVE_XC, buffer, sizeof(buffer)) &&
  109. sscanf(buffer, "%lf", &result) == 1)
  110. pProfile->get_slave_Xc() = result;
  111. if(GetDlgItemText(hdlg, IDC_EDIT_SLAVE_YC, buffer, sizeof(buffer)) &&
  112. sscanf(buffer, "%lf", &result) == 1)
  113. pProfile->get_slave_Yc() = result;
  114. if(GetDlgItemText(hdlg, IDC_EDIT_SLAVE_ZC, buffer, sizeof(buffer)) &&
  115. sscanf(buffer, "%lf", &result) == 1)
  116. pProfile->get_slave_Zc() = result;
  117. if(GetDlgItemText(hdlg, IDC_EDIT_SLAVE_PSI, buffer, sizeof(buffer)) &&
  118. sscanf(buffer, "%lf", &result) == 1)
  119. pProfile->get_slave_Psi() = result;
  120. if(GetDlgItemText(hdlg, IDC_EDIT_SLAVE_THETA, buffer, sizeof(buffer)) &&
  121. sscanf(buffer, "%lf", &result) == 1)
  122. pProfile->get_slave_Theta() = result;
  123. if(GetDlgItemText(hdlg, IDC_EDIT_SLAVE_PHI, buffer, sizeof(buffer)) &&
  124. sscanf(buffer, "%lf", &result) == 1)
  125. pProfile->get_slave_Phi() = result;
  126. LabelNoPassword:
  127. case IDCANCEL:
  128. // Restore Window procedure for alls edit control
  129. for(wIdc = IDC_EDIT_MASTER_XC; wIdc <= IDC_EDIT_SLAVE_PHI; ++wIdc)
  130. SetWindowLong(GetDlgItem(hdlg, wIdc), GWL_WNDPROC,
  131. (LONG)lpfnOldWndProc);
  132. EndDialog(hdlg, wParam);
  133. return TRUE;
  134. case IDC_BUTTON_PASSWORD:
  135. GetDlgItemText(hdlg, IDC_EDIT_PASSWORD, buffer, sizeof(buffer));
  136. for(wIdc = 0; pProfile->SettingsPassword()[wIdc]; ++wIdc)
  137. if(buffer[wIdc] != pProfile->SettingsPassword()[wIdc])
  138. {
  139. SetFocus(GetDlgItem(hdlg, IDC_EDIT_PASSWORD));
  140. SetDlgItemText(hdlg, IDC_EDIT_PASSWORD, "");
  141. SetDlgItemText(hdlg, IDC_STATIC_STATE_ERROR,
  142. "Wrong password, access deny");
  143. return TRUE;
  144. }
  145. fEnable = TRUE;
  146. // Set focus ans selection to first edit control
  147. SetFocus(GetDlgItem(hdlg, IDC_EDIT_MASTER_XC));
  148. SendMessage(GetDlgItem(hdlg, IDC_EDIT_MASTER_XC), EM_SETSEL,
  149. (WPARAM)0, (LPARAM)-1L);
  150. SetDlgItemText(hdlg, IDC_STATIC_STATE_ERROR,
  151. "Enter data to the fields");
  152. // Reset read only for alls edit control
  153. for(wIdc = IDC_EDIT_MASTER_XC; wIdc <= IDC_EDIT_SLAVE_PHI; ++wIdc)
  154. {
  155. SendMessage(GetDlgItem(hdlg, wIdc), EM_SETREADONLY,
  156. (WPARAM)FALSE, (LPARAM)0L);
  157. }
  158. return TRUE;
  159. } // end of switch(LOWORD(wParam))
  160. } // end of switch(msg)
  161. return FALSE;
  162. }