📄 hyperspectraldatauncompressdlg.cpp
字号:
// HyperspectralDataUnCompressDlg.cpp : implementation file
//
#include "stdafx.h"
#include <math.h>
#include ".\AdvanceJPEG-LS\AdvanceJPEG-LSCode.h"
#include "HyperspectralImagCode.h"
#include "HyperspectralDataUnCompress.h"
#include "HyperspectralDataUnCompressDlg.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()
/////////////////////////////////////////////////////////////////////////////
// CHyperspectralDataUnCompressDlg dialog
CHyperspectralDataUnCompressDlg::CHyperspectralDataUnCompressDlg(CWnd* pParent /*=NULL*/)
: CDialog(CHyperspectralDataUnCompressDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CHyperspectralDataUnCompressDlg)
m_AllowCompare = FALSE;
m_AuxWidth = _T("");
m_BandNumber = _T("");
m_BandPrediction = _T("");
m_BitsPerPixel = _T("");
m_CompressFileName = _T("");
m_CompressRate = _T("");
m_ConstuctFileName = _T("");
m_ImageFileName = _T("");
m_ImageFormat = _T("");
m_ImageHeight = _T("");
m_ImageWidth = _T("");
m_MaxError = _T("");
m_MaxErrPerPixel = _T("");
m_NoticeNumber = _T("");
m_PSNRString = _T("");
m_RateString = _T("");
m_NoticeString = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
CompleteUnCompressFileNumber=CompressFileNumbers=0;
AllowReport=FALSE;
CanUnCompress=FALSE;
CanCompare=FALSE;
UnCompressThreadRun=FALSE;
m_pUnCompressThread=NULL;
IsHyperspectralCompressData=FALSE;
HyperspectralDataFormat=BFILE;
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CHyperspectralDataUnCompressDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CHyperspectralDataUnCompressDlg)
DDX_Check(pDX, IDC_ALLOW_COMPARE_CHECK, m_AllowCompare);
DDX_Text(pDX, IDC_AUX_WIDTH_STATIC, m_AuxWidth);
DDX_Text(pDX, IDC_BAND_NUMBER_STATIC, m_BandNumber);
DDX_Text(pDX, IDC_BAND_PREDICTION_STATIC, m_BandPrediction);
DDX_Text(pDX, IDC_BITS_PER_PIXEL_STATIC, m_BitsPerPixel);
DDX_Text(pDX, IDC_COMPRESS_FILE_NAME, m_CompressFileName);
DDX_Text(pDX, IDC_COMPRESS_RATE_STATIC, m_CompressRate);
DDX_Text(pDX, IDC_CONSTRUCT_IMAGE_FILE_NAME, m_ConstuctFileName);
DDX_Text(pDX, IDC_IMAGE_FILE_NAME, m_ImageFileName);
DDX_Text(pDX, IDC_IMAGE_FORMAT_STATIC, m_ImageFormat);
DDX_Text(pDX, IDC_IMAGE_HEIGHT_STATIC, m_ImageHeight);
DDX_Text(pDX, IDC_IMAGE_WIDTH_STATIC, m_ImageWidth);
DDX_Text(pDX, IDC_MAX_ERROR_STATIC, m_MaxError);
DDX_Text(pDX, IDC_MAXERR_PER_PIXEL_STATIC, m_MaxErrPerPixel);
DDX_Text(pDX, IDC_NOTICE_NUMBER_STATIC, m_NoticeNumber);
DDX_Text(pDX, IDC_PSNR_STATIC, m_PSNRString);
DDX_Text(pDX, IDC_RATE_STATIC, m_RateString);
DDX_Text(pDX, IDC_NOTICE_STATIC, m_NoticeString);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CHyperspectralDataUnCompressDlg, CDialog)
ON_MESSAGE(WM_USER_HYPERSPECTRAL_UNCOMPRESS_DLG, OnHyperspectralDataUnCompressRecvMessage)
//{{AFX_MSG_MAP(CHyperspectralDataUnCompressDlg)
ON_WM_SYSCOMMAND()
ON_WM_DESTROY()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_CLOSE()
ON_EN_KILLFOCUS(IDC_COMPRESS_FILE_NAME, OnKillfocusCompressFileName)
ON_BN_CLICKED(IDC_COMPRESS_FILENAME_FIND_BUTTON, OnCompressFilenameFindButton)
ON_BN_CLICKED(IDC_MULBAND_IMAGE_FILENAME_FIND_BUTTON, OnMulbandImageFilenameFindButton)
ON_BN_CLICKED(IDC_CONSTRUCT_FILENAME_FIND_BUTTON, OnConstructFilenameFindButton)
ON_BN_CLICKED(IDC_UNCOMPRESS_CANCEL, OnUncompressCancel)
ON_BN_CLICKED(IDC_UNCOMPRESS_OK, OnUncompressOk)
ON_BN_CLICKED(IDC_ALLOW_COMPARE_CHECK, OnAllowCompareCheck)
ON_EN_KILLFOCUS(IDC_CONSTRUCT_IMAGE_FILE_NAME, OnKillfocusConstructImageFileName)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CHyperspectralDataUnCompressDlg message handlers
LRESULT CHyperspectralDataUnCompressDlg::OnHyperspectralDataUnCompressRecvMessage(WPARAM wParam, LPARAM lParam)
{
int i;
DWORD dwStatus;
CString s;
if(wParam==0)
{
i=lParam;
m_NoticeNumber.Format(_T("完成 %d%%"),i);
UpdateData(FALSE);
}
else if(wParam==1)
{
if(UnCompressThreadRun==FALSE)
{
if (m_pUnCompressThread != NULL)
{
VERIFY(::GetExitCodeThread(m_pUnCompressThread->m_hThread, &dwStatus));
if (dwStatus != STILL_ACTIVE)
{
m_NoticeString=_T("");
m_NoticeNumber=_T("");
GetDlgItem(IDC_UNCOMPRESS_CANCEL)->SetWindowText(_T("取消"));
GetDlgItem(IDC_UNCOMPRESS_OK)->EnableWindow(TRUE);
GetDlgItem(IDC_COMPRESS_FILE_NAME)->EnableWindow(TRUE);
GetDlgItem(IDC_COMPRESS_FILENAME_FIND_BUTTON)->EnableWindow(TRUE);
GetDlgItem(IDC_MULBAND_IMAGE_FILENAME_FIND_BUTTON)->EnableWindow(TRUE);
GetDlgItem(IDC_CONSTRUCT_FILENAME_FIND_BUTTON)->EnableWindow(TRUE);
GetDlgItem(IDC_ALLOW_COMPARE_CHECK)->EnableWindow(TRUE);
GetDlgItem(IDC_IMAGE_FILE_NAME)->EnableWindow(TRUE);
GetDlgItem(IDC_CONSTRUCT_IMAGE_FILE_NAME)->EnableWindow(TRUE);
delete m_pUnCompressThread;
m_pUnCompressThread = NULL;
if(UnCompressComplete==TRUE)
{
if((CompleteUnCompressFileNumber+1)<CompressFileNumbers)
{
CompleteUnCompressFileNumber++;
m_CompressFileName=lpCompressFile[CompleteUnCompressFileNumber];
UpdateData(FALSE);
PostMessage(WM_USER_HYPERSPECTRAL_UNCOMPRESS_DLG,4,0);
}
else
{
UpdateData(FALSE);
if(AllowReport==TRUE)
{
OutString(Report);
}
}
}
else
{
UpdateData(FALSE);
if(AllowReport==TRUE)
{
OutString(Report);
}
}
}
else PostMessage(WM_USER_HYPERSPECTRAL_UNCOMPRESS_DLG,1,lParam);
}
}
else
{
UnCompressThreadRun=FALSE;
PostMessage(WM_USER_HYPERSPECTRAL_UNCOMPRESS_DLG,1,lParam);
//消息处理过程可为别的线程提供运行的机会。
}
}
else if(wParam==2)
{
m_NoticeString.Format(_T("正在进行比较 ..."));
UpdateData(FALSE);
}
else if(wParam==3)
{
i=lParam;
m_NoticeNumber.Format(_T("完成 %d%% "),i);
UpdateData(FALSE);
}
else if(wParam==4)
{
if(LoadHyperspectralCompressHead(m_CompressFileName)==TRUE)
{
IsHyperspectralCompressData=TRUE;
GetDlgItem(IDC_CONSTRUCT_IMAGE_FILE_NAME)->EnableWindow(IsHyperspectralCompressData);
GetDlgItem(IDC_CONSTRUCT_FILENAME_FIND_BUTTON)->EnableWindow(IsHyperspectralCompressData);
ProduceConstructFileName();
UpdateData(FALSE);
}
else GotoDlgCtrl(GetDlgItem(IDC_COMPRESS_FILE_NAME));
PostMessage(WM_USER_HYPERSPECTRAL_UNCOMPRESS_DLG,5,0);
}
else if(wParam==5)
{
OnUncompressOk();
}
else if(wParam==6)
{
UpdateData(FALSE);
}
return 0;
}
void CHyperspectralDataUnCompressDlg::OutString(CString str,LPCTSTR lpOutFile)
{
CString OutFile;
int i;
TCHAR asc[512],WindowsDir[512];
GetWindowsDirectory(WindowsDir,512);
LPSTR lpStr;
CMapFile DMF;
if(lpOutFile==NULL)
{
strcpy(asc,(LPCTSTR)m_CompressFileName);
for(i=m_CompressFileName.GetLength()-1;i>=0&&asc[i]!='.'&&asc[i]!='\\'&&asc[i]!=':';i--);
if(asc[i]=='.')asc[i-3]='\0';
OutFile=asc;
OutFile+=_T("Un.txt");
}
else OutFile=lpOutFile;
CString windpath;
windpath=WindowsDir;
windpath+=_T("\\NOTEPAD ");
windpath+=OutFile;
if(DMF.CreateFileMap((LPCTSTR)OutFile,
PAGE_READWRITE,
str.GetLength()+1,
NULL,
CREATE_ALWAYS)!=NULL)
{//输出产生的结果
lpStr=(LPSTR)DMF.MapOfFile(0,str.GetLength()+1);
MoveMemory(lpStr,str.GetBuffer(str.GetLength()),str.GetLength());
lpStr[str.GetLength()]='\0';
DMF.Close();
}
WinExec( (LPCTSTR)windpath,SW_SHOWNORMAL);
}
BOOL CHyperspectralDataUnCompressDlg::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
// TODO: Add extra initialization here
CompressFileNumbers=0;
CompleteUnCompressFileNumber=0;
Report.Empty();
AllowReport=FALSE;
CanUnCompress=FALSE;
IsHyperspectralCompressData=FALSE;
m_AllowCompare=TRUE;
GetDlgItem(IDC_CONSTRUCT_IMAGE_FILE_NAME)->EnableWindow(IsHyperspectralCompressData);
GetDlgItem(IDC_CONSTRUCT_FILENAME_FIND_BUTTON)->EnableWindow(IsHyperspectralCompressData);
GetDlgItem(IDC_IMAGE_FILE_NAME)->EnableWindow(m_AllowCompare);
GetDlgItem(IDC_MULBAND_IMAGE_FILENAME_FIND_BUTTON)->EnableWindow(m_AllowCompare);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
}
void CHyperspectralDataUnCompressDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -