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

📄 quakefilemanager.cpp

📁 本程序源码是为日本一家地震监测机构编写的
💻 CPP
字号:
// QuakeManager.cpp: implementation of the CQuakeFileManager class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "QuakeFileManager.h"

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

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CQuakeFileManager::CQuakeFileManager()
{
	m_CurReadTime    = 0;       //起始时间点为0
	m_ReadTimeStep   = 1;       //默认Step为1

	m_MaxDisp        = 0;
	m_DataTimeLength = 0;
}

CQuakeFileManager::~CQuakeFileManager()
{
	Clear();
}

void CQuakeFileManager::Clear()
{
	m_CurReadTime    = 0;       //起始时间点为0
	m_ReadTimeStep   = 1;       //默认Step为1
	
	m_MaxDisp        = 0;
	m_DataTimeLength = 0;
	
	for(int i = 0; i < m_pQuakefileList.GetSize(); i++)
	{
		delete m_pQuakefileList[i];
	}
	m_pQuakefileList.RemoveAll();
	m_ArrayPathName.RemoveAll();
}

void CQuakeFileManager::GetPNArray(const CQFArray &QFArray)
{
	m_ArrayPathName.RemoveAll();
	for(int i = 0; i < QFArray.GetSize(); i++)
	{
		m_ArrayPathName.Add(QFArray.GetAt(i).DataFPName);
	}
}

void CQuakeFileManager::AddPathName(CString pathname)
{
	m_ArrayPathName.InsertAt(0,pathname);   
}

void CQuakeFileManager::ClearPathName()
{
	m_ArrayPathName.RemoveAll();
}

BOOL CQuakeFileManager::Load(void StepInt(int),BOOL bReLoad/* = FALSE*/)
{
	if(m_ArrayPathName.GetSize() == 0)return FALSE;
	CQuakeFile* pQuakeFile;
	int iPathSize = m_ArrayPathName.GetSize();
	int iFileListSize = m_pQuakefileList.GetSize();
	//确定最终的FileList长度
	if(iPathSize < iFileListSize)
	{//截去多于的文件对象
		for(int i = iPathSize; i < iFileListSize; i++)
			delete m_pQuakefileList[i];
		m_pQuakefileList.SetSize(iPathSize);
	}
	else
	{
		int iadditem = iPathSize - iFileListSize;
		for(int j = 0; j < iadditem; j++)
		{
			pQuakeFile=new CQuakeFile;
			m_pQuakefileList.Add(pQuakeFile);
		}
	}
	//LoadFile & Update m_MaxDisp
	for(int n = 0; n < m_pQuakefileList.GetSize(); n++)
	{
		if(m_pQuakefileList[n]->LoadFile(m_ArrayPathName.GetAt(n),bReLoad))
		{
			if(m_MaxDisp < m_pQuakefileList[n]->GetAbsMaxdisp())
				m_MaxDisp = m_pQuakefileList[n]->GetAbsMaxdisp();
			if(n == 0)
				m_DataTimeLength = m_pQuakefileList[n]->GetDataSize();
			else if(m_DataTimeLength > m_pQuakefileList[n]->GetDataSize())
				m_DataTimeLength = m_pQuakefileList[n]->GetDataSize();
		}
		StepInt(n);
	}

	return TRUE;
}

void CQuakeFileManager::SetTimeStep(int iStep/* =1 */)
{
	m_ReadTimeStep = iStep;
}

void CQuakeFileManager::ResetCurReadTime(int itime/* = 0*/)
{
	m_CurReadTime = itime;
}

BOOL CQuakeFileManager::GetDispData(int index, int itime, double &disp) const
{	
	if(m_pQuakefileList.GetSize() == 0
		|| index < 0 || index > (m_pQuakefileList.GetSize() - 1))
		return FALSE;
	DispStruct dispitem;
	BOOL bGet = m_pQuakefileList[index]->GetDispData(itime,dispitem);
	if(bGet)disp = dispitem.Disp;
	return bGet;
}

BOOL CQuakeFileManager::GetStepData(int index,DispStruct &dispitem) const
{
	if(m_pQuakefileList.GetSize() == 0
		|| index < 0 || index > (m_pQuakefileList.GetSize() - 1))
		return FALSE;
	return m_pQuakefileList[index]->GetDispData(m_CurReadTime,dispitem);
}

BOOL CQuakeFileManager::StepInt()
{
	m_CurReadTime += m_ReadTimeStep;
	return !(m_CurReadTime >= m_DataTimeLength);
}

double CQuakeFileManager::GetAbsMaxdisp() const
{
	return m_MaxDisp;
}

//获得指定索引file的最大值
double CQuakeFileManager::GetAbsMaxdisp(int index) const
{
	if(m_pQuakefileList.GetSize() == 0
		|| index < 0 || index > (m_pQuakefileList.GetSize() - 1))
		return 0;
	return m_pQuakefileList[index]->GetAbsMaxdisp();
}

double CQuakeFileManager::GetMinusMaxDisp(int index) const
{
	if(m_pQuakefileList.GetSize() == 0
		|| index < 0 || index > (m_pQuakefileList.GetSize() - 1))
		return 0;
	return m_pQuakefileList[index]->GetMinusMaxDisp();
}

double CQuakeFileManager::GetPlusMaxdisp(int index) const
{
	if(m_pQuakefileList.GetSize() == 0
		|| index < 0 || index > (m_pQuakefileList.GetSize() - 1))
		return 0;
	return m_pQuakefileList[index]->GetPlusMaxdisp();
}

int CQuakeFileManager::GetFileCount() const
{
	return m_ArrayPathName.GetSize();
}

CQuakeFile* CQuakeFileManager::GetFileAt(int index) const
{
	if(m_pQuakefileList.GetSize() == 0
		|| index < 0 || index > (m_pQuakefileList.GetSize() - 1))
		return NULL;
	return m_pQuakefileList[index];
}

void CQuakeFileManager::ShowList(int index, CListBox &list)
{
	list.ResetContent();
	//
	ResetCurReadTime();
	//
	CString str;
	DispStruct dispitem;
	while(GetStepData(index,dispitem))
	{
		str.Format(_T("T:%d   D:%f"),dispitem.Time,dispitem.Disp);
		list.InsertString(-1,str);
		StepInt();
	}
}

int	CQuakeFileManager::GetValidDateLength() const
{
	return m_DataTimeLength;
}

⌨️ 快捷键说明

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