229 lines
5.3 KiB
C++
229 lines
5.3 KiB
C++
// SetCameraDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "SetCameraDlg.h"
|
|
#include "cameradlg.h"
|
|
#include "axlock.h"
|
|
#include "setvideodlg.h"
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CSetCameraDlg dialog
|
|
|
|
|
|
CSetCameraDlg::CSetCameraDlg(CWnd* pParent /*=NULL*/)
|
|
: CModelessDialog(CSetCameraDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CSetCameraDlg)
|
|
m_nLatitude = 0;
|
|
m_nLongitude = 0;
|
|
m_nStepHeight = 0;
|
|
m_nStepLen = 0;
|
|
m_csState = _T("");
|
|
m_csLatitude = _T("");
|
|
m_csLongitude = _T("");
|
|
//}}AFX_DATA_INIT
|
|
m_bStart = FALSE;
|
|
m_csAviFile = _T("");
|
|
m_nColorNum = 8; //256
|
|
m_nRate = 50; //50 frame per s
|
|
}
|
|
|
|
|
|
void CSetCameraDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CModelessDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CSetCameraDlg)
|
|
DDX_Text(pDX, IDC_EDIT_LATITUDE, m_nLatitude);
|
|
DDX_Text(pDX, IDC_EDIT_LONGITUDE, m_nLongitude);
|
|
DDX_Text(pDX, IDC_EDIT_STEPHEIGHT, m_nStepHeight);
|
|
DDX_Text(pDX, IDC_EDIT_STEPLEN, m_nStepLen);
|
|
DDX_Text(pDX, IDC_STATIC_LATITUDE, m_csLatitude);
|
|
DDX_Text(pDX, IDC_STATIC_LONGITUDE, m_csLongitude);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CSetCameraDlg, CModelessDialog)
|
|
//{{AFX_MSG_MAP(CSetCameraDlg)
|
|
ON_WM_CLOSE()
|
|
ON_WM_CTLCOLOR()
|
|
ON_WM_DESTROY()
|
|
ON_BN_CLICKED(IDC_BT_CAMERA, OnBtCamera)
|
|
ON_BN_CLICKED(IDC_VIDEO_SETTING, OnVideoSetting)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CSetCameraDlg message handlers
|
|
|
|
void CSetCameraDlg::PostNcDestroy()
|
|
{
|
|
CModelessDialog::PostNcDestroy();
|
|
// delete this;
|
|
}
|
|
|
|
|
|
void CSetCameraDlg::OnClose()
|
|
{
|
|
CModelessDialog::OnClose();
|
|
acedPostCommand(_T("\33\33"));
|
|
}
|
|
|
|
|
|
BOOL CSetCameraDlg::AddTip(UINT idControl)
|
|
{
|
|
HINSTANCE hInstance=NULL;
|
|
CWnd *pWnd = GetDlgItem(idControl);
|
|
if (!pWnd)
|
|
return FALSE;
|
|
|
|
int nRet;
|
|
CString strTip;
|
|
if (!hInstance) {
|
|
nRet=strTip.LoadString(idControl);
|
|
} else {
|
|
TCHAR szTemp[1024]=_T("");
|
|
nRet=::LoadString(hInstance, idControl, szTemp, 1023);
|
|
if (nRet)
|
|
strTip=szTemp;
|
|
}
|
|
|
|
if (nRet)
|
|
nRet=m_wndToolTip.AddTool(pWnd,strTip);
|
|
return (nRet!=0);
|
|
}
|
|
|
|
|
|
|
|
|
|
HBRUSH CSetCameraDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
|
{
|
|
HBRUSH hbr = CModelessDialog::OnCtlColor(pDC, pWnd, nCtlColor);
|
|
if (pWnd->IsWindowEnabled()) {
|
|
CToolInfo toolInfo;
|
|
if (m_wndToolTip.GetToolInfo(toolInfo, pWnd)) {
|
|
pDC->SetTextColor(RGB(0,0,255));
|
|
}
|
|
}
|
|
|
|
|
|
// TODO: Return a different brush if the default is not desired
|
|
return hbr;
|
|
}
|
|
|
|
BOOL CSetCameraDlg::OnInitDialog()
|
|
{
|
|
CModelessDialog::OnInitDialog();
|
|
m_wndToolTip.Create(this);
|
|
m_wndToolTip.Activate(true);
|
|
m_wndToolTip.SetMaxTipWidth(250);
|
|
m_wndToolTip.SetDelayTime(TTDT_AUTOPOP, 4*m_wndToolTip.GetDelayTime(TTDT_AUTOPOP));
|
|
|
|
AddTip(IDC_EDIT_STEPLEN);
|
|
AddTip(IDC_EDIT_STEPHEIGHT);
|
|
AddTip(IDC_EDIT_LONGITUDE);
|
|
AddTip(IDC_EDIT_LATITUDE);
|
|
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
BOOL CSetCameraDlg::PreTranslateMessage(MSG* pMsg)
|
|
{
|
|
if (pMsg->message >= WM_MOUSEFIRST &&
|
|
pMsg->message <= WM_MOUSELAST) {
|
|
MSG msg;
|
|
::CopyMemory(&msg, pMsg, sizeof(MSG));
|
|
HWND hWndParent = ::GetParent(msg.hwnd);
|
|
//while (hWndParent && hWndParent != m_hWnd) {
|
|
// msg.hwnd = hWndParent;
|
|
// hWndParent = ::GetParent(hWndParent);
|
|
//}
|
|
if (msg.hwnd) {
|
|
m_wndToolTip.RelayEvent(&msg);
|
|
}
|
|
}
|
|
return CModelessDialog::PreTranslateMessage(pMsg);
|
|
}
|
|
|
|
void CSetCameraDlg::OnDestroy()
|
|
{
|
|
CModelessDialog::OnDestroy();
|
|
m_wndToolTip.DestroyWindow();
|
|
// TODO: Add your message handler code here
|
|
|
|
}
|
|
|
|
void CSetCameraDlg::OnBtCamera()
|
|
{
|
|
AcDbDatabase *dwg = acdbCurDwg();
|
|
AcAxDocLock docLock(dwg); //解除锁定
|
|
VERIFY(docLock.lockStatus() == Acad::eOk);
|
|
|
|
OPENOBJ_BEGIN(m_entity, AcDb::kForRead, TDbCamera, pCam);
|
|
if (!pCam)
|
|
return;
|
|
|
|
CAcModuleResourceOverride vTemp;
|
|
CCameraDlg dlg(this);
|
|
dlg.Obj2Dlg(pCam);
|
|
if (dlg.DoModal() == IDOK) {
|
|
if (pCam->upgradeOpen()!=Acad::eOk)
|
|
return;
|
|
dlg.Dlg2Obj(pCam);
|
|
pCam->downgradeOpen();
|
|
if (pCam->IsActive()) {
|
|
pCam->draw();
|
|
pCam->TakePhoto(FALSE);
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
}
|
|
|
|
void CSetCameraDlg::OnVideoSetting()
|
|
{
|
|
m_bStart = !m_bStart;
|
|
CWnd *pWndBT = GetDlgItem(IDC_VIDEO_SETTING);
|
|
if (m_bStart){
|
|
if (m_csAviFile.IsEmpty()){
|
|
CAcModuleResourceOverride vTemp;
|
|
CFileDialog dlg(TRUE,_T("*.avi"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
|
_T("上华录影文件 (*.avi) |*.AVI||"),this); // sr modify
|
|
if (dlg.DoModal()!=IDOK){
|
|
pWndBT->SetWindowText(_T("●开始摄像"));
|
|
m_bStart = FALSE;
|
|
return;
|
|
}
|
|
m_csAviFile = dlg.GetPathName();
|
|
if (FindFile(m_csAviFile)) {
|
|
m_csAviFile = _T("");
|
|
AfxMessageBox(_T("已存在此文件!请换一文件。"));
|
|
pWndBT->SetWindowText(_T("●开始摄像"));
|
|
m_bStart = FALSE;
|
|
return;
|
|
}
|
|
CSetVideoDlg dlg2;
|
|
if (dlg2.DoModal()!=IDOK) {
|
|
pWndBT->SetWindowText(_T("●开始摄像"));
|
|
m_bStart = FALSE;
|
|
return;
|
|
}
|
|
|
|
m_nRate = dlg2.m_nRate;
|
|
}
|
|
pWndBT->SetWindowText(_T("■停止摄像"));
|
|
}
|
|
else {
|
|
pWndBT->SetWindowText(_T("●开始摄像"));
|
|
|
|
}
|
|
}
|