Files
envi-code/SourceCode/Code2026/tg_shs/shs_kerncmd/CameraDlg.cpp
T
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

214 lines
6.0 KiB
C++

// CameraDlg.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "CameraDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCameraDlg dialog
IMPLEMENT_DYNAMIC(CCameraDlg, CToolTipDialog)
CCameraDlg::CCameraDlg(CWnd* pParent /*=NULL*/)
: CToolTipDialog(CCameraDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCameraDlg)
m_strBackClipDist = _T("");
m_bActive = FALSE;
m_strCameraElev = _T("");
m_strLen = _T("");
m_bPerspective = FALSE;
m_bBackClip = FALSE;
m_bFrontClip = FALSE;
m_strFrontClipDist = _T("");
m_strLatitude = _T("");
m_strLongitude = _T("");
m_strTargetElev = _T("");
m_nFrontAtCamera = 0;
//}}AFX_DATA_INIT
m_bEdit=TRUE;
}
void CCameraDlg::DoDataExchange(CDataExchange* pDX)
{
CToolTipDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCameraDlg)
DDX_Text(pDX, IDC_BACKCLIP_DIST, m_strBackClipDist);
DDX_Check(pDX, IDC_CAMERA_ACTIVE, m_bActive);
DDX_Text(pDX, IDC_CAMERA_ELEV, m_strCameraElev);
DDX_Text(pDX, IDC_CAMERA_LEN, m_strLen);
DDX_Check(pDX, IDC_CAMERA_PERSPECTIVE, m_bPerspective);
DDX_Check(pDX, IDC_CHECK_BACKCLIP, m_bBackClip);
DDX_Check(pDX, IDC_CHECK_FRONTCLIP, m_bFrontClip);
DDX_Text(pDX, IDC_FRONTCLIP_DIST, m_strFrontClipDist);
DDX_Text(pDX, IDC_LATITUDE, m_strLatitude);
DDX_Text(pDX, IDC_LONGITUDE, m_strLongitude);
DDX_Text(pDX, IDC_TARGET_ELEV, m_strTargetElev);
DDX_Radio(pDX, IDC_FRONT_ATCAMERA, m_nFrontAtCamera);
//}}AFX_DATA_MAP
//if (pDX->m_bSaveAndValidate && _tstof(m_strFrontClipDist)<_DIST_SNAP)
// pDX->Fail();
}
BEGIN_MESSAGE_MAP(CCameraDlg, CToolTipDialog)
//{{AFX_MSG_MAP(CCameraDlg)
ON_WM_PAINT()
ON_EN_KILLFOCUS(IDC_LATITUDE, TargetElev)
ON_BN_CLICKED(IDC_CHECK_FRONTCLIP, OnClip)
ON_BN_CLICKED(IDC_CHECK_BACKCLIP, OnClip)
ON_BN_CLICKED(IDC_FRONT_ATCAMERA, OnClip)
ON_BN_CLICKED(IDC_FRONT_DIST_TEXT, OnClip)
ON_EN_KILLFOCUS(IDC_CAMERA_ELEV, TargetElev)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCameraDlg message handlers
void CCameraDlg::Dlg2Obj(TDbCamera *pStep) // 对话框数据传向实体
{
pStep->SetLens(_tstof(m_strLen));
pStep->SetElevation(_tstof(m_strCameraElev), TRUE);
pStep->SetLongitude(_tstof(m_strLongitude) * PI / 180.0);
// pStep->SetElevation(_tstof(m_strTargetElev), FALSE);
pStep->SetActive(m_bActive);
pStep->SetPerspective(m_bPerspective);
pStep->SetFrontClipOn(m_bFrontClip);
pStep->SetBackClipOn(m_bBackClip);
pStep->SetFrontClipAtEye(!m_nFrontAtCamera);
if (m_bFrontClip) {
pStep->SetFrontClipDist(_tstof(m_strFrontClipDist));
}
if (m_bBackClip) {
pStep->SetBackClipDist(_tstof(m_strBackClipDist));
}
pStep->SetLatitude(_tstof(m_strLatitude) * PI / 180.0);
return;
}
void CCameraDlg::Obj2Dlg(const TDbCamera *pStep) // 实体数据传向对话框
{
m_ptCamera=pStep->GetCamera();
m_ptTarget=pStep->GetTarget();
m_strLen = (const TCHAR *)Dist2Str(pStep->GetLens()); // 焦距
m_strLongitude = (const TCHAR *)Angle2Str(pStep->GetLongitude() * 180.0 / PI); // 经角
m_strLatitude = (const TCHAR *)Angle2Str(pStep->GetLatitude() * 180.0 / PI); // 纬角
m_strCameraElev = (const TCHAR *)Dist2Str(pStep->GetElevation(TRUE));
m_strTargetElev = (const TCHAR *)Dist2Str(pStep->GetElevation(FALSE));
m_bActive = pStep->IsActive();
m_bPerspective = pStep->IsPerspective(); // 透视
m_strFrontClipDist = (const TCHAR *)Dist2Str(pStep->GetFrontClipDist());
m_strBackClipDist = (const TCHAR *)Dist2Str(pStep->GetBackClipDist());
m_bFrontClip = pStep->IsFrontClipOn();
m_bBackClip = pStep->IsBackClipOn();
m_nFrontAtCamera = !pStep->IsFrontClipAtEye();
return;
}
BOOL CCameraDlg::OnInitDialog()
{
CToolTipDialog::OnInitDialog();
GetDlgItem(IDC_LONGITUDE)->EnableWindow(m_bEdit);
GetDlgItem(IDC_LATITUDE)->EnableWindow(m_bEdit);
AddTip(IDC_CAMERA_ACTIVE);
AddTip(IDC_CHECK_FRONTCLIP);
AddTip(IDC_CHECK_BACKCLIP);
AddTip(IDC_LONGITUDE_TEXT);
AddTip(IDC_LATITUDE_TEXT);
// TODO: Add extra initialization here
OnClip();
OpenSlide();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CCameraDlg::OnClip()
{
UpdateData(TRUE);
CWnd *pWnd1 = GetDlgItem(IDC_FRONT_ATCAMERA);
CWnd *pWnd2 = GetDlgItem(IDC_FRONTCLIP_DIST);
CWnd *pWnd3 = GetDlgItem(IDC_BACKCLIP_DIST);
CWnd *pWnd4 = GetDlgItem(IDC_FRONT_DIST_TEXT);
if (m_bFrontClip) { //打开前裁剪
pWnd2->EnableWindow(m_nFrontAtCamera);
pWnd1->EnableWindow(TRUE);
pWnd4->EnableWindow(TRUE);
} else {
pWnd1->EnableWindow(FALSE);
pWnd2->EnableWindow(FALSE);
pWnd4->EnableWindow(FALSE);
}
if (m_bBackClip) //打开后裁剪
pWnd3->EnableWindow(TRUE);
else
pWnd3->EnableWindow(FALSE);
}
void CCameraDlg::OpenSlide()
{
//XString m_strFilePath;
CWnd *pImageBox=GetDlgItem(IDC_SLIDE);
if (pImageBox) {
CDC *pDC=pImageBox->GetDC();
CRect rc;
pImageBox->GetClientRect(&rc);
m_slideDc.InitDC(pDC, rc, GetAcadBackColor());
m_slideDc.PaintSlide(_T("TArch(Camera)"));
m_slideDc.SetDC(NULL);
pImageBox->ReleaseDC(pDC);
}
}
void CCameraDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rcClip, rcImage;
dc.GetClipBox(&rcClip);
CWnd *pImageBox=GetDlgItem(IDC_SLIDE);
if (pImageBox) {
pImageBox->GetWindowRect(&rcImage);
ScreenToClient(&rcImage);
if (!rcImage.IntersectRect(&rcImage, &rcClip))
return;
CDC *pDC=pImageBox->GetDC();
m_slideDc.SetDC(pDC);
m_slideDc.Redraw();
m_slideDc.SetDC(NULL);
pImageBox->ReleaseDC(pDC);
}
}
void CCameraDlg::TargetElev()
{
TDbCamera *pStep=new TDbCamera;
UpdateData(TRUE);
pStep->SetCamera(m_ptCamera);
pStep->SetTarget(m_ptTarget);
Dlg2Obj(pStep);
m_strTargetElev = (const TCHAR *)Dist2Str(pStep->GetElevation(FALSE));
UpdateData(FALSE);
delete pStep;
}