📄 equalmixeddistdlg.cpp
字号:
// EqualMixedDistDlg.cpp : implementation file
//
#include "stdafx.h"
#include "RSIP.h"
#include "EqualMixedDistDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEqualMixedDistDlg dialog
CEqualMixedDistDlg::CEqualMixedDistDlg(CWnd* pParent /*=NULL*/)
: CDialog(CEqualMixedDistDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CEqualMixedDistDlg)
m_nClassNum = 10;
m_nImageHeight = 0;
m_nImageWidth = 0;
m_dStandE = 5.0;
//}}AFX_DATA_INIT
m_nImageCount = 0;
}
CEqualMixedDistDlg::~CEqualMixedDistDlg()
{
CString *pszTemp;
for(int i=0; i<m_nImageCount; i++)
{
pszTemp = (CString *)(m_aImageArray[i]);
delete pszTemp;
}
m_aImageArray.RemoveAll();
}
void CEqualMixedDistDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEqualMixedDistDlg)
DDX_Control(pDX, IDC_IMAGELIST, m_ImageList);
DDX_Text(pDX, IDC_CLASSNUM, m_nClassNum);
DDV_MinMaxInt(pDX, m_nClassNum, 2, 255);
DDX_Text(pDX, IDC_IMAGEHEIGHT, m_nImageHeight);
DDX_Text(pDX, IDC_IMAGEWIDTH, m_nImageWidth);
DDX_Text(pDX, IDC_STDE, m_dStandE);
DDV_MinMaxDouble(pDX, m_dStandE, 0., 100.);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CEqualMixedDistDlg, CDialog)
//{{AFX_MSG_MAP(CEqualMixedDistDlg)
ON_BN_CLICKED(IDC_REMOVEIMAGE, OnRemoveimage)
ON_BN_CLICKED(IDC_BROWSEFILE, OnBrowsefile)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEqualMixedDistDlg message handlers
void CEqualMixedDistDlg::OnRemoveimage()
{
int nCurSel = m_ImageList.GetCurSel();
if(nCurSel<0)
return;
CString *pszTemp;
pszTemp = (CString *)(m_aImageArray[nCurSel]);
delete pszTemp;
m_aImageArray.RemoveAt(nCurSel);
m_ImageList.DeleteString(nCurSel);
m_ImageList.SetCurSel(0);
m_nImageCount --;
}
void CEqualMixedDistDlg::OnBrowsefile()
{
CFileDialog fileDlg(TRUE,"*.DAT",
NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_ALLOWMULTISELECT,
"Image Files(*.dat)|*.dat||",this);
char lpstrFile[32764];
lpstrFile[0]='\0';
fileDlg.m_ofn.lpstrFile=lpstrFile;
fileDlg.m_ofn.nMaxFile=32764;
if ( fileDlg.DoModal() == IDOK )
{
POSITION pos = fileDlg.GetStartPosition();
while ( pos != NULL )
{
CString * lpstrPathName = new CString();
*lpstrPathName = fileDlg.GetNextPathName( pos );
if(m_nImageCount == 0)
{
CString szInfFileName;
CFile infFile;
lpstrPathName->TrimLeft();
lpstrPathName->TrimRight();
szInfFileName = lpstrPathName->Left(lpstrPathName->GetLength()-4) + ".inf";
if(0 != infFile.Open(szInfFileName,CFile::modeRead))
{
infFile.Seek(2*sizeof(DWORD)+sizeof(int)+258,CFile::begin);
infFile.Read(&m_nImageWidth,sizeof(int));
infFile.Read(&m_nImageHeight,sizeof(int));
SetDlgItemInt(IDC_IMAGEWIDTH,m_nImageWidth);
SetDlgItemInt(IDC_IMAGEHEIGHT,m_nImageHeight);
infFile.Close();
}
CFile File;
if(0 == File.Open(*lpstrPathName,CFile::modeRead))
{
MessageBox("打不开数据文件!",
"错误",
MB_OK|MB_ICONINFORMATION);
delete lpstrPathName;
return;
}
if(File.GetLength() != m_nImageWidth * m_nImageHeight)
{
MessageBox("文件大小不匹配!",
"错误",
MB_OK|MB_ICONINFORMATION);
File.Close();
delete lpstrPathName;
return;
}
File.Close();
}
else
{
CFile File;
if(0 == File.Open(*lpstrPathName,CFile::modeRead))
{
MessageBox("打不开数据文件!",
"错误",
MB_OK|MB_ICONINFORMATION);
delete lpstrPathName;
return;
}
if(File.GetLength() != m_nImageWidth*m_nImageHeight)
{
MessageBox("文件大小不匹配!",
"错误",
MB_OK|MB_ICONINFORMATION);
File.Close();
delete lpstrPathName;
return;
}
File.Close();
}
m_ImageList.AddString(*lpstrPathName);
m_ImageList.SetCurSel(m_nImageCount);
m_aImageArray.Add(lpstrPathName);
m_nImageCount ++;
}
}
}
void CEqualMixedDistDlg::OnOK()
{
UpdateData();
if(m_dStandE < 0)
{
MessageBox("标准差限制输入值错误!",
"错误",
MB_OK|MB_ICONINFORMATION);
return;
}
if(m_nImageCount<=2)
{
MessageBox("必须至少选取三幅图象",
"错误",
MB_OK|MB_ICONINFORMATION);
return;
}
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -