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

📄 rsip.cpp

📁 基于小波的SAR斑点处理
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// RSIP.cpp : Defines the class behaviors for the application.
//

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

#include "MainFrm.h"
#include "ChildFrm.h"
#include "RSIPDoc.h"
#include "RSIPView.h"
#include "Progress.h"

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

#define ID_UPDATESTATUSBAR 5003
/////////////////////////////////////////////////////////////////////////////
// CRSIPApp

BEGIN_MESSAGE_MAP(CRSIPApp, CWinApp)
	//{{AFX_MSG_MAP(CRSIPApp)
	ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
	ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
	ON_COMMAND(ID_UPDATESTATUSBAR,OnUpdateStatusBar)
	ON_COMMAND(ID_FILE_IMPORT, OnFileImport)
	//}}AFX_MSG_MAP
	// Standard file based document commands
	ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
	ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
	// Standard print setup command
	ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CRSIPApp construction

CRSIPApp::CRSIPApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CRSIPApp object

CRSIPApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CRSIPApp initialization

BOOL CRSIPApp::InitInstance()
{
	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	// Change the registry key under which our settings are stored.
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization.
	SetRegistryKey(_T("GeoSIS.PKU"));

	LoadStdProfileSettings();  // Load standard INI file options (including MRU)

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	//CMultiDocTemplate* pDocTemplate;
	pDocTemplate = new CMultiDocTemplate(
		IDR_RSIPTYPE,
		RUNTIME_CLASS(CRSIPDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(CRSIPView));
	AddDocTemplate(pDocTemplate);

	// create main MDI Frame window
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
		return FALSE;
	m_pMainWnd = pMainFrame;

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// Dispatch commands specified on the command line
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	// The main window has been initialized, so show and update it.
	pMainFrame->ShowWindow(SW_SHOWMAXIMIZED);
	pMainFrame->UpdateWindow();

	m_nProgress = 0;
	m_nDocCount = 1;
	CreateSystemPal();

	return TRUE;
}


/////////////////////////////////////////////////////////////////////////////
// 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)
		// No message handlers
	//}}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()

// App command to run the dialog
void CRSIPApp::OnAppAbout()
{
	CAboutDlg aboutDlg;
	aboutDlg.DoModal();
}

/////////////////////////////////////////////////////////////////////////////
// CTapeImageInfo dialog

CTapeImageInfo::CTapeImageInfo(CWnd* pParent /*=NULL*/)
	: CDialog(CTapeImageInfo::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTapeImageInfo)
	m_nBandNum = 1;
	m_nImageHeight = 0;
	m_nImageWidth = 0;
	//}}AFX_DATA_INIT
}

void CTapeImageInfo::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTapeImageInfo)
	DDX_Text(pDX, IDC_BANDNUM, m_nBandNum);
	DDV_MinMaxByte(pDX, m_nBandNum, 1, 255);
	DDX_Text(pDX, IDC_IMAGEHEIGHT, m_nImageHeight);
	DDX_Text(pDX, IDC_IMAGEWIDTH, m_nImageWidth);
	//}}AFX_DATA_MAP
}

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

/////////////////////////////////////////////////////////////////////////////
// CTapeImageInfo message handlers

void CTapeImageInfo::OnOK() 
{
	CString temp = "";
	BOOL bTemp = FALSE;

	UpdateData(TRUE);
	if(m_nBandNum <= 0)
	{
		temp = temp+"波段数 ";
		bTemp = TRUE;
	}
	if(m_nImageHeight <= 0)
	{
		temp = temp+"影象高 ";
		bTemp = TRUE;
	}
	if(m_nImageWidth <= 0)
	{
		temp = temp+"影象宽";
		bTemp = TRUE;
	}
	if(bTemp) 
	{
		AfxMessageBox("\n数值输入错误!");
		return;
	}

	CDialog::OnOK();
}

/////////////////////////////////////////////////////////////////////////////
// CRSIPApp message handlers

void CRSIPApp::CreateSystemPal()
{
	int i;
	BYTE Col[3];
	CFile File;
	CString szFileName = "RSIP.PAL";
	if(0 != File.Open(szFileName,CFile::modeRead))
	{
		for(i=0; i<256; i++)
		{
			File.Read(Col,3*sizeof(BYTE));
			m_pSystemPal[i] = RGB(Col[0],Col[1],Col[2]);
		}
		File.Close();
	}
	else
	{
		for(int i=0; i<256; i++)
		{
			m_pSystemPal[i] = RGB((double)rand()/RAND_MAX*255,
				(double)rand()/RAND_MAX*255,
				(double)rand()/RAND_MAX*255);
		}
		File.Open(szFileName,CFile::modeCreate|CFile::modeWrite);
		for(i=0; i<256; i++)
		{
			Col[0] = GetRValue(m_pSystemPal[i]);
			Col[1] = GetGValue(m_pSystemPal[i]);
			Col[2] = GetBValue(m_pSystemPal[i]);

			File.Write(Col,3*sizeof(BYTE));
		}
		File.Close();
	}
}

void CRSIPApp::OnFileOpen() 
{
	CFileDialog dlg(TRUE,"dat",NULL,
		OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_FILEMUSTEXIST,
		"Image Files(*.dat,*.raw)|*.dat;*raw||",NULL);
	if(dlg.DoModal() == IDOK)
		OpenDocumentFile(dlg.GetPathName());
}

void CRSIPApp::OnUpdateStatusBar()
{
	RECT Rect;
	m_nProgress++;
	if(m_nProgress==100)
		m_nProgress = 0;

	CStatusBar  *pStatusBar = &(((CMainFrame *)m_pMainWnd)->m_wndStatusBar);
	pStatusBar->GetStatusBarCtrl().GetRect( 1 , &Rect );
	Rect.right = Rect.left+(Rect.right-Rect.left)*m_nProgress/100;
	CDC *pDC = pStatusBar->GetDC();

	if(m_nProgress!=0)
	{
		CBrush Brush(RGB(0,0,128));
		CBrush *pOldBrush;
		pOldBrush = pDC->SelectObject(&Brush);
		pDC->Rectangle(&Rect);
		pDC->SelectObject(pOldBrush);
		pStatusBar->UpdateWindow();
	}
	else
	{
		pStatusBar->Invalidate();
		((CMainFrame *)m_pMainWnd)->GetActiveFrame()->SetFocus();
	}
}

void CRSIPApp::CreateNewImageDoc(CRSImage * pRSImage,LPCTSTR szDocName)
{
	CRSIPDoc * pDocument = ( CRSIPDoc * )pDocTemplate->CreateNewDocument();
	if (pDocument == NULL)
	{
		TRACE0("CDocTemplate::CreateNewDocument returned NULL.\n");
		AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
		return;
	}
	ASSERT_VALID(pDocument);
	
	BOOL bAutoDelete = pDocument->m_bAutoDelete;
	pDocument->m_bAutoDelete = FALSE;   // don't destroy if something goes wrong
	CFrameWnd* pFrame = pDocTemplate->CreateNewFrame(pDocument, NULL);
	pDocument->m_bAutoDelete = bAutoDelete;
	if (pFrame == NULL)
	{
		AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
		delete pDocument;       // explicit delete on error
		return;
	}
	ASSERT_VALID(pFrame);

	m_nDocCount++;
	
	//Evaluation: 
	CTime Time;
	Time = CTime::GetCurrentTime();
	
	pRSImage->m_dwDateOfImage = Time.GetDay()+Time.GetMonth()*100+Time.GetYear()*10000;
	pDocument->m_pRSImage = pRSImage;
	pDocument->SetTitle(szDocName);

⌨️ 快捷键说明

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