📄 zd_set.cpp
字号:
// Zd_set.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "Zd_set.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "Aygshell.h"
/////////////////////////////////////////////////////////////////////////////
// CZd_set dialog
//extern CDzctApp theApp;
CZd_set::CZd_set(CWnd* pParent /*=NULL*/)
: CDialog(CZd_set::IDD, pParent)
{
//{{AFX_DATA_INIT(CZd_set)
m_qw = 36.5;
m_yqg = 0.0;
m_zdm = _T("");
m_qy = 786;
m_zbz = _T("埋石");
m_cbdm = _T("");
m_czj = TRUE;
m_jl = TRUE;
m_spj = TRUE;
m_dxjs = FALSE;
m_cty = _T("");
//}}AFX_DATA_INIT
theApp.fxs=0;
theApp.czj_rec_len=theApp.spj_rec_len=theApp.jl_rec_len=0;
}
void CZd_set::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CZd_set)
DDX_Control(pDX, IDC_CHECK_SPJ, m_SPJ);
DDX_Control(pDX, IDC_CHECK_JL, m_JL);
DDX_Control(pDX, IDC_CHECK_CZJ, m_CZJ);
DDX_Control(pDX, IDC_CBDM, m_CBDM);
DDX_Text(pDX, IDC_QW, m_qw);
DDX_Text(pDX, IDC_YQG, m_yqg);
DDX_Text(pDX, IDC_ZDM, m_zdm);
DDX_Text(pDX, IDC_QY, m_qy);
DDX_CBString(pDX, IDC_ZBZ, m_zbz);
DDX_Text(pDX, IDC_CBDM, m_cbdm);
DDX_Check(pDX, IDC_CHECK_CZJ, m_czj);
DDX_Check(pDX, IDC_CHECK_JL, m_jl);
DDX_Check(pDX, IDC_CHECK_SPJ, m_spj);
DDX_Check(pDX, IDC_DXJS, m_dxjs);
DDX_Text(pDX, IDC_CTY, m_cty);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CZd_set, CDialog)
//{{AFX_MSG_MAP(CZd_set)
ON_BN_CLICKED(ID_ADD, OnAdd)
ON_EN_SETFOCUS(IDC_ZDM, OnSetfocus)
ON_EN_KILLFOCUS(IDC_ZDM, OnKillfocus)
ON_CBN_SELCHANGE(IDC_CBDM, OnSelchange)
ON_EN_SETFOCUS(IDC_QW, OnSetfocus)
ON_EN_KILLFOCUS(IDC_QW, OnKillfocus)
ON_EN_KILLFOCUS(IDC_QY, OnKillfocus)
ON_EN_SETFOCUS(IDC_QY, OnSetfocus)
ON_EN_KILLFOCUS(IDC_YQG, OnKillfocus)
ON_EN_SETFOCUS(IDC_YQG, OnSetfocus)
ON_CBN_KILLFOCUS(IDC_ZBZ, OnKillfocus)
ON_CBN_SETFOCUS(IDC_ZBZ, OnSetfocus)
ON_EN_KILLFOCUS(IDC_CBDM, OnKillfocus)
ON_EN_SETFOCUS(IDC_CBDM, OnSetfocus)
ON_CBN_KILLFOCUS(IDC_CBDM, OnKillfocus)
ON_CBN_SETFOCUS(IDC_CBDM, OnSetfocus)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CZd_set message handlers
void CZd_set::OnOK()
{
// TODO: Add extra validation here
UpdateData(true);
CTime t = CTime::GetCurrentTime();
time_t osBinaryTime = t.GetTime(); // time_t defined in <time.h>
m_zdm.TrimLeft();
m_zdm.TrimRight();
if(m_zdm.Compare(_T(""))==0)
{
if(MessageBox(_T("测站名为空"),_T("测站名"),MB_OKCANCEL)!=IDOK)
{
GetDlgItem(IDC_ZDM)->SetFocus();
return;
}
}
if(m_yqg<=0)
{
if(MessageBox(_T("仪器高为零或负数"),_T("仪器高"),MB_OKCANCEL)!=IDOK)
{
GetDlgItem(IDC_YQG)->SetFocus();
return;
}
}
CString str;
if(!theApp.DataBase.OpenTable(theApp.DataBase.szFileName,_T("DXSYB")))
{
AfxMessageBox(_T("请确定一个工程"));
return;
}
else
{
theApp.DataBase.m_values.RemoveAll();
//站点存盘
theApp.DataBase.m_values.Add(m_zdm);
theApp.DataBase.m_values.Add(m_zbz);
str.Format(_T("%5.1f+%5.1f"),m_qw,m_qy);
theApp.DataBase.m_values.Add(str);
switch(theApp.yq.yqmc)
{
case 0:
theApp.DataBase.m_values.Add(_T("拓扑康"));
break;
}
str=theApp.yq.yqbh;
theApp.DataBase.m_values.Add(str);
str.Format(_T("%6.3f"),m_yqg);
theApp.DataBase.m_values.Add(str);
str.Format(_T("%d"),m_CBDM.GetCount());
theApp.DataBase.m_values.Add(str);
if(m_dxjs)//导线结束
{
theApp.DataBase.m_values.Add(_T("TT"));
}
else
{
theApp.DataBase.m_values.Add(_T("FF"));
}
theApp.zdrec.Format(_T("%d"),theApp.DataBase.GetRecordNumber());
theApp.DataBase.m_values.Add(theApp.zdrec);
// AfxMessageBox(theApp.zdrec);
theApp.DataBase.m_values.Add(m_cty);
theApp.cty=m_cty;
str.Format(_T("%ld"), osBinaryTime );
theApp.DataBase.m_values.Add(str);
if(!theApp.DataBase.AddNewRecord())
{
AfxMessageBox(_T("导线索引表添加记录不成功"));
theApp.DataBase.CloseTable();
}
// theApp.zdrec.Format(_T("%d"),theApp.DataBase.GetRecordNumber());
theApp.DataBase.CloseTable();
}
//计算水平方向数个数
for(int m=0;m<theApp.fxmc.GetSize();m++)
{
if(theApp.fxmc.GetAt(m)->spj)
{
str=theApp.fxmc.GetAt(m)->cdm;
if(str.Find(_T("_"))<0)
theApp.spj_rec_len++;
}
}
if(theApp.spj_rec_len>3)
{
FXMC *mobj=new FXMC;
wcscpy(mobj->cdm,_T("归零向"));
mobj->czj=false;
mobj->jl=false;
mobj->spj=true;
if(theApp.cz_high!=-10.0)
mobj->cbg=theApp.cz_high;
theApp.fxmc.Add(mobj);
theApp.fxs++;
theApp.spj_rec_len++;
}
clsx();
if(writetab())
CDialog::OnOK();
else
CDialog::OnCancel();
//测量顺序
;
}
//增加方向
void CZd_set::OnAdd()
{
// TODO: Add your control notification handler code here
UpdateData(true);
int index=theApp.fxmc.GetSize();
CString str;
if(m_cbdm.Compare(_T(""))==0)
return;
m_cbdm.TrimLeft();
m_cbdm.TrimRight();
for(int i=0;i<index;i++)
{
str.Format(_T("%s"),theApp.fxmc.GetAt(i)->cdm);
if(str.Compare(m_cbdm)==0)
{
theApp.fxmc.GetAt(i)->czj=m_czj;
theApp.fxmc.GetAt(i)->jl=m_jl;
theApp.fxmc.GetAt(i)->spj=m_spj;
return;
}
}
FXMC *mobj=new FXMC;
wcscpy(mobj->cdm,m_cbdm);
mobj->czj=m_czj;
mobj->jl=m_jl;
mobj->spj=m_spj;
mobj->cbg=searchcbg();
theApp.fxmc.Add(mobj);
m_CBDM.AddString(m_cbdm);
theApp.fxs++;
if(theApp.fxs>0)//正常应为1
GetDlgItem(IDOK)->EnableWindow(true);
}
int CZd_set::chs(int i, int j, int l)
{
//求最大测回数
int temp;
i>j ? temp=i:temp=j;
temp>l ? i=temp:i= l;
return i;
}
void CZd_set::OnSetfocus()
{
// TODO: Add your control notification handler code here
SHSipPreference(AfxGetMainWnd()->m_hWnd,SIP_UP);
}
void CZd_set::OnKillfocus()
{
// TODO: Add your control notification handler code here
SHSipPreference(AfxGetMainWnd()->m_hWnd,SIP_DOWN);
}
void CZd_set::OnCancel()
{
FXMC *mobj;
int index=theApp.fxmc.GetSize();
while(index>0)
{
mobj=theApp.fxmc.GetAt(0);
theApp.fxmc.RemoveAt(0);
index=theApp.fxmc.GetSize();
delete mobj;
}
CDialog::OnCancel();
}
void CZd_set::OnSelchange() //
{
// TODO: Add your control notification handler code here
UpdateData(true);
int sel= m_CBDM.GetCurSel();
m_CZJ.SetCheck(theApp.fxmc.GetAt(sel)->czj);
m_JL.SetCheck(theApp.fxmc.GetAt(sel)->jl);
m_SPJ.SetCheck(theApp.fxmc.GetAt(sel)->spj);
}
double CZd_set::searchcbg()//搜索觇标高
{
int i,rec;
UpdateData(true);
CString str;
double cbg=-10;
if(theApp.fxs==0)
{
if(!theApp.DataBase.OpenTable(theApp.DataBase.szFileName,_T("DXSYB")))
{
AfxMessageBox(_T("不能打开DXSYB"));
return cbg;
}
rec=theApp.DataBase.GetRecordNumber();
if(rec>0)
{
for(i=0;i<rec;i++)
{
theApp.DataBase.ReadRecord(i);
if(m_cbdm.Compare(theApp.DataBase.m_values.GetAt(0))==0)
cbg=m_wtof(theApp.DataBase.m_values.GetAt(5));
}
}
theApp.DataBase.CloseTable();
}
else
{
if(!theApp.DataBase.OpenTable(theApp.DataBase.szFileName,_T("DXCZJ")))
{
AfxMessageBox(_T("不能打开DXCZJ"));
return cbg;
}
rec=theApp.DataBase.GetRecordNumber();
if(rec>0)
{
for(i=0;i<rec;i++)
{
theApp.DataBase.ReadRecord(i);
if(m_cbdm.Compare(theApp.DataBase.m_values.GetAt(2))==0)
cbg=m_wtof(theApp.DataBase.m_values.GetAt(3));
}
}
theApp.DataBase.CloseTable();
}
return cbg;
}
double CZd_set::m_wtof(CString str)
{
char buf [250];
buf[0]='\0';
int i,len=wcslen(str);
for(i=0;i<len;i++)
{
switch(str.GetAt(i))
{
case '-':
buf[i]='-';
buf[i+1]='\0';
break;
case '.':
buf[i]='.';
buf[i+1]='\0';
break;
case '0':
buf[i]='0';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -