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
208 lines
7.1 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 10/04/2001
|
|
// Last modification: 08/10/2003
|
|
// Project Intruder Position Indicator
|
|
// SUBSYSTEM: Camera calibration dialog
|
|
// FILE: CalibDlg.cpp
|
|
// AUTHOR: Belkovsky Joseph
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source of implementation of the Camera calibration dialog
|
|
//----------------------------------------------------------------------------
|
|
|
|
#include "stdafx.h"
|
|
#include "..\LgLib\Version.h"
|
|
|
|
#include "CalibDlg.h"
|
|
#include "Profile.h"
|
|
|
|
static WNDPROC lpfnOldWndProc;// Old Window Procedure for class "edit"
|
|
|
|
LRESULT CALLBACK NewEditProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
{
|
|
switch(message)
|
|
{
|
|
case WM_CHAR:
|
|
if(isdigit(wParam) || wParam == '.' || wParam == '-' ||
|
|
wParam == 0x08 || wParam == '+' || toupper(wParam) == 'E')
|
|
CallWindowProc(lpfnOldWndProc, hWnd, message, wParam, lParam);
|
|
|
|
return 0L;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return CallWindowProc(lpfnOldWndProc, hWnd, message, wParam, lParam);
|
|
}
|
|
|
|
BOOL CALLBACK CalibDlgProc(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
{
|
|
static CProfile* pProfile;
|
|
static BOOL fEnable;
|
|
|
|
double result;
|
|
WORD wIdc;
|
|
char buffer[0x500];
|
|
|
|
switch(msg)
|
|
{
|
|
case WM_INITDIALOG:
|
|
pProfile = (CProfile*)lParam;
|
|
|
|
fEnable = FALSE;
|
|
|
|
SetDlgItemText(hdlg, IDC_STATIC_STATE_ERROR,
|
|
"To write information, enter password");
|
|
|
|
_sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_master_Xc() );
|
|
SetDlgItemText(hdlg, IDC_EDIT_MASTER_XC, buffer);
|
|
_sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_master_Yc() );
|
|
SetDlgItemText(hdlg, IDC_EDIT_MASTER_YC, buffer );
|
|
_sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_master_Zc() );
|
|
SetDlgItemText(hdlg, IDC_EDIT_MASTER_ZC, buffer );
|
|
_sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_master_Psi() );
|
|
SetDlgItemText(hdlg, IDC_EDIT_MASTER_PSI, buffer );
|
|
_sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_master_Theta() );
|
|
SetDlgItemText(hdlg, IDC_EDIT_MASTER_THETA, buffer );
|
|
_sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_master_Phi() );
|
|
SetDlgItemText(hdlg, IDC_EDIT_MASTER_PHI, buffer );
|
|
|
|
_sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_slave_Xc() );
|
|
SetDlgItemText(hdlg, IDC_EDIT_SLAVE_XC, buffer);
|
|
_sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_slave_Yc() );
|
|
SetDlgItemText(hdlg, IDC_EDIT_SLAVE_YC, buffer );
|
|
_sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_slave_Zc() );
|
|
SetDlgItemText(hdlg, IDC_EDIT_SLAVE_ZC, buffer );
|
|
_sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_slave_Psi() );
|
|
SetDlgItemText(hdlg, IDC_EDIT_SLAVE_PSI, buffer );
|
|
_sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_slave_Theta() );
|
|
SetDlgItemText(hdlg, IDC_EDIT_SLAVE_THETA, buffer );
|
|
_sntprintf( buffer, MAX_PATH, _T("%0.2f"), pProfile->get_slave_Phi() );
|
|
SetDlgItemText(hdlg, IDC_EDIT_SLAVE_PHI, buffer );
|
|
|
|
// Set read only for alls edit control
|
|
for(wIdc = IDC_EDIT_MASTER_XC; wIdc <= IDC_EDIT_SLAVE_PHI; ++wIdc)
|
|
{
|
|
SendMessage(GetDlgItem(hdlg, wIdc), EM_SETREADONLY,
|
|
(WPARAM)TRUE, (LPARAM)0L);
|
|
}
|
|
|
|
// Change Window procedure for alls edit control
|
|
lpfnOldWndProc = (WNDPROC)GetWindowLong(GetDlgItem(hdlg, IDC_EDIT_MASTER_XC),
|
|
GWL_WNDPROC);
|
|
for(wIdc = IDC_EDIT_MASTER_XC; wIdc <= IDC_EDIT_SLAVE_PHI; ++wIdc)
|
|
SetWindowLong(GetDlgItem(hdlg, wIdc), GWL_WNDPROC,
|
|
(LONG)NewEditProc);
|
|
|
|
return TRUE;
|
|
|
|
case WM_COMMAND:
|
|
switch(LOWORD(wParam))
|
|
{
|
|
case IDOK:
|
|
if(!fEnable)
|
|
goto LabelNoPassword;
|
|
|
|
if(GetDlgItemText(hdlg, IDC_EDIT_MASTER_XC, buffer, sizeof(buffer)) &&
|
|
sscanf(buffer, "%lf", &result) == 1)
|
|
pProfile->get_master_Xc() = result;
|
|
|
|
if(GetDlgItemText(hdlg, IDC_EDIT_MASTER_YC, buffer, sizeof(buffer)) &&
|
|
sscanf(buffer, "%lf", &result) == 1)
|
|
pProfile->get_master_Yc() = result;
|
|
|
|
if(GetDlgItemText(hdlg, IDC_EDIT_MASTER_ZC, buffer, sizeof(buffer)) &&
|
|
sscanf(buffer, "%lf", &result) == 1)
|
|
pProfile->get_master_Zc() = result;
|
|
|
|
if(GetDlgItemText(hdlg, IDC_EDIT_MASTER_PSI, buffer, sizeof(buffer)) &&
|
|
sscanf(buffer, "%lf", &result) == 1)
|
|
pProfile->get_master_Psi() = result;
|
|
|
|
if(GetDlgItemText(hdlg, IDC_EDIT_MASTER_THETA, buffer, sizeof(buffer)) &&
|
|
sscanf(buffer, "%lf", &result) == 1)
|
|
pProfile->get_master_Theta() = result;
|
|
|
|
if(GetDlgItemText(hdlg, IDC_EDIT_MASTER_PHI, buffer, sizeof(buffer)) &&
|
|
sscanf(buffer, "%lf", &result) == 1)
|
|
pProfile->get_master_Phi() = result;
|
|
|
|
if(GetDlgItemText(hdlg, IDC_EDIT_SLAVE_XC, buffer, sizeof(buffer)) &&
|
|
sscanf(buffer, "%lf", &result) == 1)
|
|
pProfile->get_slave_Xc() = result;
|
|
|
|
if(GetDlgItemText(hdlg, IDC_EDIT_SLAVE_YC, buffer, sizeof(buffer)) &&
|
|
sscanf(buffer, "%lf", &result) == 1)
|
|
pProfile->get_slave_Yc() = result;
|
|
|
|
if(GetDlgItemText(hdlg, IDC_EDIT_SLAVE_ZC, buffer, sizeof(buffer)) &&
|
|
sscanf(buffer, "%lf", &result) == 1)
|
|
pProfile->get_slave_Zc() = result;
|
|
|
|
if(GetDlgItemText(hdlg, IDC_EDIT_SLAVE_PSI, buffer, sizeof(buffer)) &&
|
|
sscanf(buffer, "%lf", &result) == 1)
|
|
pProfile->get_slave_Psi() = result;
|
|
|
|
if(GetDlgItemText(hdlg, IDC_EDIT_SLAVE_THETA, buffer, sizeof(buffer)) &&
|
|
sscanf(buffer, "%lf", &result) == 1)
|
|
pProfile->get_slave_Theta() = result;
|
|
|
|
if(GetDlgItemText(hdlg, IDC_EDIT_SLAVE_PHI, buffer, sizeof(buffer)) &&
|
|
sscanf(buffer, "%lf", &result) == 1)
|
|
pProfile->get_slave_Phi() = result;
|
|
|
|
LabelNoPassword:
|
|
case IDCANCEL:
|
|
// Restore Window procedure for alls edit control
|
|
for(wIdc = IDC_EDIT_MASTER_XC; wIdc <= IDC_EDIT_SLAVE_PHI; ++wIdc)
|
|
SetWindowLong(GetDlgItem(hdlg, wIdc), GWL_WNDPROC,
|
|
(LONG)lpfnOldWndProc);
|
|
|
|
EndDialog(hdlg, wParam);
|
|
|
|
return TRUE;
|
|
|
|
case IDC_BUTTON_PASSWORD:
|
|
GetDlgItemText(hdlg, IDC_EDIT_PASSWORD, buffer, sizeof(buffer));
|
|
|
|
for(wIdc = 0; pProfile->SettingsPassword()[wIdc]; ++wIdc)
|
|
if(buffer[wIdc] != pProfile->SettingsPassword()[wIdc])
|
|
{
|
|
SetFocus(GetDlgItem(hdlg, IDC_EDIT_PASSWORD));
|
|
SetDlgItemText(hdlg, IDC_EDIT_PASSWORD, "");
|
|
|
|
SetDlgItemText(hdlg, IDC_STATIC_STATE_ERROR,
|
|
"Wrong password, access deny");
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
fEnable = TRUE;
|
|
// Set focus ans selection to first edit control
|
|
SetFocus(GetDlgItem(hdlg, IDC_EDIT_MASTER_XC));
|
|
SendMessage(GetDlgItem(hdlg, IDC_EDIT_MASTER_XC), EM_SETSEL,
|
|
(WPARAM)0, (LPARAM)-1L);
|
|
|
|
SetDlgItemText(hdlg, IDC_STATIC_STATE_ERROR,
|
|
"Enter data to the fields");
|
|
|
|
// Reset read only for alls edit control
|
|
for(wIdc = IDC_EDIT_MASTER_XC; wIdc <= IDC_EDIT_SLAVE_PHI; ++wIdc)
|
|
{
|
|
SendMessage(GetDlgItem(hdlg, wIdc), EM_SETREADONLY,
|
|
(WPARAM)FALSE, (LPARAM)0L);
|
|
}
|
|
|
|
return TRUE;
|
|
} // end of switch(LOWORD(wParam))
|
|
} // end of switch(msg)
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
|
|
|