📄 水泥砼回弹仪测定数据处理程序dlg.cpp
字号:
// 水泥砼回弹仪测定数据处理程序Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "水泥砼回弹仪测定数据处理程序.h"
#include "水泥砼回弹仪测定数据处理程序Dlg.h"
#include "Tokenizer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyDlg dialog
CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMyDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMyDlg)
m_shuju = _T("");
m_htp = _T("");
m_qdp = _T("");
m_jfc = _T("");
m_dbz = _T("");
m_ff = _T("2×σ");
m_sgl = _T("");
m_wanchen = _T("");
m_xiuzheng = _T("1.0");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
button1.SubclassDlgItem(IDbb,this);
}
void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMyDlg)
DDX_Control(pDX, IDOK, button1);
DDX_Control(pDX, IDC_EDIT2, ht);
DDX_Control(pDX, IDC_EDIT1, m_txt);
DDX_Text(pDX, IDC_EDIT1, m_shuju);
DDX_Text(pDX, IDC_EDIT2, m_htp);
DDX_Text(pDX, IDC_EDIT3, m_qdp);
DDX_Text(pDX, IDC_EDIT5, m_jfc);
DDX_Text(pDX, IDC_EDIT6, m_dbz);
DDX_CBString(pDX, IDC_COMBO1, m_ff);
DDX_Text(pDX, IDC_EDIT9, m_sgl);
DDX_Text(pDX, IDC_EDIT7, m_wanchen);
DDX_Text(pDX, IDC_EDIT8, m_xiuzheng);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
//{{AFX_MSG_MAP(CMyDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
ON_WM_CTLCOLOR()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyDlg message handlers
BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
m_brush.CreateSolidBrush(RGB(192,192,200));
// TODO: Add extra initialization here
flag=1;
m_xiuzheng="1.0";
cc=-1;
dd=0;
return TRUE; // return TRUE unless you set the focus to a control
}
void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CMyDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMyDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
bool CMyDlg::FromString(CString s, const CString& sDelim /*= " "*/, BOOL bLineBreak /*= TRUE*/)
{
if(s.IsEmpty())
return false;
if(1)
{
CTokenizer kk(s,"\r\n");
CStringList ListRow;
CString sRow;
while(kk.Next(sRow))
{
sRow.TrimLeft();
sRow.TrimRight();
if(sRow.IsEmpty())
break;
ListRow.AddTail(sRow);
}
int mm=ListRow.GetCount();
sRow=ListRow.GetHead();
POSITION pos=ListRow.GetHeadPosition();
CString ss;
int k=1;
for(int i=0;i<mm;i++)
{
sRow=ListRow.GetNext(pos);
int j=0;
CTokenizer tkRow(sRow,sDelim);
while(tkRow.Next(ss))
{
ss.TrimLeft();
ss.TrimRight();
double v=atof(ss);
shuju[k]=v;
k++;
}
}
geshu=k-1;
}
return true;
}
bool CMyDlg::paixu()
{
int n=geshu;
double a;
for (int j = 2; j<=n; j++)
{
a = shuju[j];
for (int i = j - 1; i>=1; i--)
{
if (shuju[i] <= a)
{
break;
}
shuju[i + 1] = shuju[i];
}
if (shuju[i] > a)
{
i = 0;
}
shuju[i+1] = a;
}
return true;
}
void CMyDlg::OnOK()
{
// TODO: Add extra validation here
//OnChangeEdit1();
//m_sgl="";
UpdateData(true);
if(!FromString(m_shuju," "))
{MessageBox("请输入数据!");
return;
}
else
{FromString(m_shuju," ");
paixu();
double kks;
//CString teyi;
kks=atof(m_xiuzheng);
for(int k=1;k<=geshu;k++)
{
shuju[k]=2.0*shuju[k]*kks;
}
jisuan(geshu);
//int cc=-1;
smy="";
while(cc!=dd)
{ cc=dd;
tichu();
}
jisuan(geshu);
m_htp.Format("%.1f",pingjunzhi);
m_qdp.Format("%.1d",geshu);
m_jfc.Format("%.1f",junfangcha);
double ac;
ac=pingjunzhi+2.0*junfangcha;
m_dbz.Format("%.1f",ac);
//m_sgl=teyi;
UpdateData(false);
}
}
void CMyDlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
void CMyDlg::tichu()
{
// TODO: Add your control notification handler code here
CString space1=" ",tyz1;
CString space2=" ",tyz2;
//m_sgl="";
//CString smy;
OnSelchangeCombo1();
if(flag==1)
{
int kr=1;
while((fabs(shuju[kr]-pingjunzhi)>fabs(3.0*junfangcha))&&(junfangcha>=0))
{
tyz1.Format("%.3f",shuju[kr]/2.0);
tyz1=tyz1+" ";
space1+=tyz1;
for(int t=kr;t<geshu;t++)
{shuju[t]=shuju[t+1];
}
geshu=geshu-1;
kr++;
}
int jr=geshu;
while((fabs(shuju[jr]-pingjunzhi)>fabs(3.0*junfangcha))&&(junfangcha>=0))
{
tyz2.Format("%.3f",shuju[jr]/2.0);
tyz2=tyz2+" ";
space2+=tyz2;
shuju[jr]=0.0;
geshu=geshu-1;
jr--;
}
}
if(flag==2)
{
int kr=1;
while((fabs(shuju[kr]-pingjunzhi)>fabs(2.0*junfangcha))&&(junfangcha>=0))
{
tyz1.Format("%.3f",shuju[kr]/2.0);
tyz1=tyz1+" ";
space1+=tyz1;
for(int t=kr;t<geshu;t++)
{shuju[t]=shuju[t+1];
}
shuju[geshu]=0.0;
geshu=geshu-1;
kr++;
}
int jr=geshu;
while((fabs(shuju[jr]-pingjunzhi)>fabs(2.0*junfangcha))&&(junfangcha>=0))
{
tyz2.Format("%.3f",shuju[jr]/2.0);
tyz2=tyz2+" ";
space2+=tyz2;
//geshu=geshu-1;
shuju[jr]=0.0;
geshu=geshu-1;
jr--;
}
}
CString s1=" ",s2=" ",ss1,ss2;
for(int tk=1;tk<=geshu;tk++)
{
ss1.Format("%.3f",shuju[tk]);
ss1=ss1+" ";
s1+=ss1;
ss2.Format("%.3f",shuju[tk]/2.0);
ss2=ss2+" ";
s2+=ss2;
}
dd=geshu;
CString su;
m_wanchen=s1;
m_shuju=s2;
su=space1+space2;
smy+=su;
m_sgl=smy;
UpdateData(false);
//return smy;
}
void CMyDlg::OnSelchangeCombo1()
{
// TODO: Add your control notification handler code here
if(m_ff=="2×σ")
flag=1;
if(m_ff=="3×σ")
flag=2;
}
bool CMyDlg::jisuan(int n)
{ double sdev;
double var;
int j;
double p,s = 0.0;
for (j = 1; j<=n; j++)
{
s = s + shuju[j];
}
double ave, adev;
adev=0;
ave=s / n;
sdev = 0;
var = 0;
for (j = 1; j<=n; j++)
{
s = shuju[j] - ave;
p = s * s;
var = var + p;
}
var = var / (n - 1);
sdev = sqrt(var);
//sdev是均方差 、var是方差。
//fangcha=var;
junfangcha=sdev;
pingjunzhi=ave;
return true;
}
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = (HBRUSH)m_brush;
if(nCtlColor==CTLCOLOR_STATIC)
{ pDC->SetBkMode(TRANSPARENT);
return hbr;
}
if(nCtlColor==CTLCOLOR_EDIT)
{
return NULL;
}
return hbr;
}
void CMyDlg::OnButton1()
{
// T ODO: Add your control notification handler code here
m_shuju = _T("");
m_htp = _T("");
m_qdp = _T("");
//m_xiuzheng = _T("1.0");
m_jfc = _T("");
m_dbz = _T("");
m_ff = _T("2×σ");
m_sgl = _T("");
m_wanchen = _T("");
UpdateData(false);
}
void CMyDlg::OnChangeEdit1()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
cc=-1;
dd=0;
// TODO: Add your control notification handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -