📄 cfiledataholder.h
字号:
#if !defined(FILEDATAHOLDER_H__8771E45F_6BD4_460E_ABAD_C04CC0998D0D__INCLUDED_)
#define FILEDATAHOLDER_H__8771E45F_6BD4_460E_ABAD_C04CC0998D0D__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#if defined(_AFXDLL)
#include <afxwin.h>
#endif
// This pragma disables warnings about identifiers being longer than 255 in debug info
#pragma warning( disable : 4786 )
#pragma warning( disable : 4503 )
#include <math.h>
#include <float.h>
#include <map>
#include <string>
class CFileDataHolder {
public:
CFileDataHolder();
const float * GetDataPtr(void){
return m_pData;
}
static double m_singleProfileHeight;
#if defined(_AFXDLL)
virtual void Draw(CDC &dc, CRect drawRc, bool bShowIASP91 = false) = 0;
virtual bool LoadData( const char * filename = NULL ) = 0;
void Magnify2Window( const CRect wRc, const CRect drawRc ) {
float vScale = CFileDataHolder::m_singleProfileHeight/float(wRc.Height());
float hScale = drawRc.Width()/float(wRc.Width());
m_bDrawIndex += (wRc.left - drawRc.left)/m_hScale;// locate to the mouse selected
// change the scale
m_vScale *= vScale;
m_hScale *= int(hScale);
}
void MagnifyVertScale(float fScale = 0.0f) {
if( FLT_EPSILON > abs(fScale) ) // fScale is zero
m_vScale += 1;
else
m_vScale *= fScale;
}
void MinifyVertScale(void) {
if( m_vScale > 1 )
--m_vScale;
else
m_vScale /= 2;
}
void MagnifyHorizScale(int nStep = 0 ) {
if( 0 == nStep )
m_hScale += 1;
else
m_hScale += nStep;
}
void MinifyHorizScale(void) {
m_hScale > 1 ? --m_hScale : m_hScale = 1;
}
void MouseMoveHoriz(int nStep = 0 ) {
m_bDrawIndex -= floor(nStep/m_hScale + _copysign(0.5, nStep) );
m_bDrawIndex < 0 ? m_bDrawIndex = 0 : NULL;
m_bDrawIndex > m_npts ? m_bDrawIndex = m_npts - 1 : NULL;
}
static void ResetScale(void) {
m_hScale = 1.0;
m_vScale = 1.0;
}
void SetbDrawIndex4GoPos( long pos, int width ) {
m_bDrawIndex = pos - width/2/m_hScale;
m_bDrawIndex < 0 ? m_bDrawIndex = 0 : NULL;
m_bDrawIndex > m_npts ? m_bDrawIndex = m_npts - 1 : NULL;
}
virtual long GetPhaseDrawPos( int indexPhase = 0 ) = 0;
// 传入屏幕距离,返回占用数据点个数
int GetNptsByWidth( int width ) {
return width/m_hScale;
}
double GetDelta(void) {
return m_delta;
}
// 默认得到当前能显示出图形的开始时间
// scrnOffset 偏移的数据点在屏幕的位置
virtual CTime & GetTime( CTime & time, double & delta, int scrnOffset = 0 ) = 0;
virtual void Align2Time( const CTime & time, double delta ) = 0;
void GetFileBaseTime( CTime & time );
void Show( BOOL bShow ) {
m_bShow = bShow;
}
BOOL Show(void) {
return m_bShow;
}
#endif
bool CalcIASP91(void);
std::map<float, std::string> & GetIASP91map(void) {
return m_IASP91;
}
// 获取分量名称标识字符
char GetCmpNm(void) {
return m_cmpnm;
}
void GetStationLoc(float & lat, float & lon) {
lat = m_StLa;
lon = m_StLo;
}
void GetEventLoc( float & lat, float & lon) {
lat = m_EvLa;
lon = m_EvLo;
}
protected:
std::map<float, std::string> m_IASP91; // key is phase, value is the arrival time.
float *m_pData;
float m_dataMean, m_dataMin, m_dataMax;
int m_npts; // points in the file.
double m_delta; // 等间隔采样点之间的增量
double m_StLa; // station latitude, unit is degree
double m_StLo; // station longitude, unit is degree
double m_EvLa; // event latitude, unit is degree
double m_EvLo; // event longitude, unit is degree
double m_gcArc; // 台站到事件的大圆弧长度, unit is degree
double m_EvDp; // event deep, unit is kilometer
double m_EvBegin; // 事件发生时间,相对基准时间, unit is second
double m_begin; // 自变量开始值
double m_end;
// 文件基准时间(计时起点)
int m_nzYear; // GMT年
int m_nzjDay; // GMT儒略日
int m_nzHour;
int m_nzMinute;
int m_nzSecond;
int m_nzMSec;
double m_FirstPhaseTm; //初动到时,相对基准时间,unit is second
char m_cmpnm; //分量名称, e 东西向分量,n 南北向分量,z 垂直分量
long m_bDrawIndex; // 数据开始绘制的索引
long m_eDrawIndex;
static double m_vScale; // vertical scale factor
static double m_hScale; // horizontal step increment
short daysInMonth(int month, int year) {
int m[] = {31,28,31,30,31,30,31,31,30,31,30,31};
if (month != 2) return m[month - 1];
if (year%4 != 0) return m[1];
if (year%100 == 0 && year%400 != 0) return m[1];
return m[1] + 1;
}
private:
#if defined(_AFXDLL)
BOOL m_bShow;
#endif
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -