⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kltransformdlg.cpp

📁 基于小波的SAR斑点处理
💻 CPP
字号:
// KLTransformDlg.cpp : implementation file
//

#include "stdafx.h"
#include "RSIP.h"
#include "KLTransformDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CKLTransformDlg dialog


CKLTransformDlg::CKLTransformDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CKLTransformDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CKLTransformDlg)
	m_nImageHeight = 0;
	m_nImageWidth = 0;
	m_nSampleRate = 4;
	//}}AFX_DATA_INIT
	m_nImageCount = 0;
}

CKLTransformDlg::~CKLTransformDlg()
{
	CString *pszTemp;
	for(int i=0; i<m_nImageCount; i++)
	{
		pszTemp = (CString *)(m_aFileNameArray[i]);
		delete pszTemp;
	}
	m_aFileNameArray.RemoveAll();
}

void CKLTransformDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CKLTransformDlg)
	DDX_Control(pDX, IDC_IMAGELIST, m_ImageList);
	DDX_Text(pDX, IDC_IMAGEHEIGHT, m_nImageHeight);
	DDX_Text(pDX, IDC_IMAGEWIDTH, m_nImageWidth);
	DDX_Text(pDX, IDC_SAMPLERATE, m_nSampleRate);
	DDV_MinMaxInt(pDX, m_nSampleRate, 1, 16);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CKLTransformDlg, CDialog)
	//{{AFX_MSG_MAP(CKLTransformDlg)
	ON_BN_CLICKED(IDC_ADDIMAGE, OnAddimage)
	ON_BN_CLICKED(IDC_REMOVEIMAGE, OnRemoveimage)
	ON_BN_CLICKED(IDC_RESET, OnReset)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CKLTransformDlg message handlers

void CKLTransformDlg::OnAddimage() 
{
	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_aFileNameArray.Add(lpstrPathName);
			
			m_nImageCount ++;
		}
	}
}

void CKLTransformDlg::OnRemoveimage() 
{
	int nCurSel = m_ImageList.GetCurSel();
	if(nCurSel < 0)
		return;

	CString *pszTemp;
	pszTemp = (CString *)(m_aFileNameArray[nCurSel]);
	delete pszTemp;

	m_aFileNameArray.RemoveAt(nCurSel);
	
	m_ImageList.DeleteString(nCurSel);
	m_ImageList.SetCurSel(0);

	m_nImageCount --;
}

void CKLTransformDlg::OnReset() 
{
	CString *pszTemp;
	for(int i=0;i<m_nImageCount;i++)
	{
		pszTemp = (CString *)(m_aFileNameArray[i]);
		delete pszTemp;
	}
	m_aFileNameArray.RemoveAll();
	m_nImageCount = 0;
	m_ImageList.ResetContent();
	
	m_nImageHeight = 0;
	m_nImageWidth = 0;
	m_nSampleRate = 4;
	
	SetDlgItemInt(IDC_IMAGEWIDTH,m_nImageWidth);
	SetDlgItemInt(IDC_IMAGEHEIGHT,m_nImageHeight);
	SetDlgItemInt(IDC_SAMPLERATE,m_nSampleRate);
}

void CKLTransformDlg::OnOK() 
{
	if(m_nImageCount <= 2)
	{
		MessageBox("你必须至少选择三幅图象",
			"错误",
			MB_OK|MB_ICONINFORMATION);
		return;
	}
	
	CDialog::OnOK();
}

/////////////////////////////////////////////////////////////////////////////
// CSelComponentDlg dialog

CSelComponentDlg::CSelComponentDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSelComponentDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSelComponentDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}

void CSelComponentDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSelComponentDlg)
	DDX_Control(pDX, IDC_COMPONENTLIST, m_ComponentList);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CSelComponentDlg, CDialog)
	//{{AFX_MSG_MAP(CSelComponentDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSelComponentDlg message handlers

BOOL CSelComponentDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	char szText[16];
	for(int i=0; i<m_nFileNum; i++)
	{
		sprintf(szText,"%.2f",m_pdLamda[i]);
		m_ComponentList.AddString(szText);
		if(m_pbSelectVec[i])
			m_ComponentList.SetCheck(i,0);
		else
			m_ComponentList.SetCheck(i,1);
	}
	
	return TRUE;
}

void CSelComponentDlg::OnOK() 
{
	int nCount = 0;
	for(int i=0; i<m_nFileNum; i++)
	{
		if(1 == m_ComponentList.GetCheck(i))
		{
			m_pbSelectVec[i]=TRUE;
			nCount++;
		}
		else
			m_pbSelectVec[i]=FALSE;
	}
	if(0 == nCount)
	{
		MessageBox("你必须至少选择一个成分!",
			"错误",
			MB_OK|MB_ICONQUESTION);
		return;
	}
	
	CDialog::OnOK();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -