📄 segyviewdoc.cpp
字号:
// SegyViewDoc.cpp : implementation of the CSegyViewDoc class
//
#include "stdafx.h"
#include "SegyView.h"
#include "SegyViewDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSegyViewDoc
IMPLEMENT_DYNCREATE(CSegyViewDoc, CDocument)
BEGIN_MESSAGE_MAP(CSegyViewDoc, CDocument)
//{{AFX_MSG_MAP(CSegyViewDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSegyViewDoc construction/destruction
CSegyViewDoc::CSegyViewDoc()
{
// TODO: add one-time construction code here
m_nBeginTrace = m_nCode = m_nEndTrace = m_nFrequency = m_nTime = 0;
m_bOpenfile = FALSE;
}
CSegyViewDoc::~CSegyViewDoc()
{
if (m_bOpenfile)
{
m_tagFile.Close();
}
}
/////////////////////////////////////////////////////////////////////////////
// CSegyViewDoc serialization
//DEL void CSegyViewDoc::Serialize(CArchive& ar)
//DEL {
//DEL if (ar.IsStoring())
//DEL {
//DEL // TODO: add storing code here
//DEL }
//DEL else
//DEL {
//DEL // TODO: add loading code here
//DEL }
//DEL }
/////////////////////////////////////////////////////////////////////////////
// CSegyViewDoc diagnostics
#ifdef _DEBUG
void CSegyViewDoc::AssertValid() const
{
CDocument::AssertValid();
}
//DEL void CSegyViewDoc::Dump(CDumpContext& dc) const
//DEL {
//DEL CDocument::Dump(dc);
//DEL }
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CSegyViewDoc commands
BOOL CSegyViewDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;
// TODO: Add your specialized creation code here
m_bOpenfile = TRUE;
CString strPathName(lpszPathName);
CString strExt = strPathName.Right(4);
strExt.MakeLower();
if (strExt != ".sgy")
{
AfxMessageBox("请选择Segy格式(.sgy)的文件!");
return FALSE;
}
CFileException fileException;
if (!m_tagFile.Open(lpszPathName, CFile::modeRead, &fileException))
{
TRACE( "Can't open file %s, error = %u\n", lpszPathName, fileException.m_cause );
return FALSE;
}
ReadValumeHeader();
return TRUE;
}
BOOL CSegyViewDoc::ReadValumeHeader()
{
//读取卷头中的相关数据
DATA data, temp;
int nTime = 0;
int nFreqeucy = 0;
int nCode = 0;
long Buffer[900] = { 0 }; // 3600 字节
m_tagFile.ReadHuge(Buffer, 3600);
temp.Long = Buffer[804];
data.ch[0] = temp.ch[3];
data.ch[1] = temp.ch[2];
data.ch[2] = temp.ch[1];
data.ch[3] = temp.ch[0];
m_nTime = data.Long >> 16; //采样间隔
temp.Long = Buffer[805];
data.ch[0] = temp.ch[3];
data.ch[1] = temp.ch[2];
data.ch[2] = temp.ch[1];
data.ch[3] = temp.ch[0];
m_nFrequency = data.Long >> 16; // 每道样点数
temp.Long = Buffer[806];
data.ch[0] = temp.ch[3];
data.ch[1] = temp.ch[2];
data.ch[2] = temp.ch[1];
data.ch[3] = temp.ch[0];
m_nCode = data.Long >> 16; //采样格式
// 读取第一道的道顺序号
m_tagFile.Read(&temp.Long, 4);
data.ch[0] = temp.ch[3];
data.ch[1] = temp.ch[2];
data.ch[2] = temp.ch[1];
data.ch[3] = temp.ch[0];
m_nBeginTrace = data.Long;
// 计算总共道数
int nTotal = 0;
if (m_nCode == 3)
nTotal = (m_tagFile.GetLength() - 3600) / (240 + m_nFrequency * 2);
else
nTotal = (m_tagFile.GetLength() - 3600) / (240 + m_nFrequency * 4);
m_nEndTrace = m_nBeginTrace + nTotal - 1;
CProperitiesDialog dialog;
dialog.m_editTime.Format("%d", m_nTime);
dialog.m_editFrequency.Format("%d", m_nFrequency);
dialog.m_editBeginTrace.Format("%d", m_nBeginTrace);
dialog.m_editEndTrace.Format("%d", m_nEndTrace);
dialog.m_radioDataType = (m_nCode == 5) ? m_nCode - 2: m_nCode - 1;
if (dialog.DoModal() == IDOK)
UpdateAllViews(NULL);
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -