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

📄 clplot.h

📁 一个网络监视的程序
💻 H
字号:
//*******************************************************************************************************/
//* FileName        : clPlot.h
//* Description	    : Real Time Plot for MFC
//* Contents:		: axis		y (x) axis info.
//*					  timeaxis	time axis info
//*					  legend	legend info.
//*					  serie		data serie info & array
//*					  clPlot	The plot itself.
//* Author          : Jan Vidar Berger, Modified by Bill Chen
//* Time			: 2004.7.20	xianch@126.com
//*******************************************************************************************************/

#if !defined(AFX_DQPLOT_H__0D536D37_5CF1_11D1_AED1_0060973A08A4__INCLUDED_)
#define AFX_DQPLOT_H__0D536D37_5CF1_11D1_AED1_0060973A08A4__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// clPlot.h : header file
//
#define SERIENUMBER		5
#define MAXSIRIEDATA	140	// 60 * 2, 每格最多两个数据
#define COORWIDTH	35	// 坐标数值的宽度

//*******************************************************************************************************/
//* simple data value struct. used in dynamic array
//*******************************************************************************************************/
typedef struct _value{
	double	dValue;
	CTime	ValueTime;
}value;

//*******************************************************************************************************/
//* non-time axis. used for left and right y axis. might be used for x as well.
//*******************************************************************************************************/
class  AFX_EXT_CLASS axis
{
public:
	double	minrange;
	double	maxrange;
	double	m_dValuePrPixel;

	axis()
	{
		minrange	= 0.0;
		maxrange	= 200.0;
		m_dValuePrPixel = 1;
	};
};

//*******************************************************************************************************/
//* time axis
//*******************************************************************************************************/
class  AFX_EXT_CLASS timeaxis
{
public:
	CString		m_szTitle;		// time axis title;
	CTime		m_mintime;		// min time
	CTime		m_maxtime;		// max time
	int			m_iTimeMode;	// axis grid and legend interval index

	double		m_dSecondsPrPixel;	//时间间隔(秒)/画图区宽度

	timeaxis()
	{
		m_szTitle = "Time";
		m_mintime = 0;
		m_maxtime = 600;
		m_iTimeMode = 0;
		m_dSecondsPrPixel = 1;
	}
};

//*******************************************************************************************************/
//* legend
//*******************************************************************************************************/
/*
class  AFX_EXT_CLASS legend
{
public:
	COLORREF	m_color;		// legend color code
	int			m_istyle;
	CString		m_szTitle;		// legend title

	legend(){
		m_color		= 0;
		m_istyle	= PS_SOLID;
		m_szTitle	= "";
	}
};
*/

/*******************************************************************************************************
//* data serie
	改进的循环队列, 元素个数为 #define MAXSIRIEDATA	120 + 1 个,
	开始时, m_lbegin == m_lend
	访问数据时, 若 m_lbegin != m_lend, go on!

*******************************************************************************************************/
class  AFX_EXT_CLASS serie
{
public:
	COLORREF	m_color;		// serie line color
	int			m_iLineStyle;	// line style
	value		m_pvalues[MAXSIRIEDATA];		// value array
	int		m_lbegin;		// list begin
	int		m_lend;			// list end

	// Added later
	int m_nMinValue;
	int m_nMaxValue;
	CString m_strTitle;

	serie();
	~serie();

	void AddPoint(CTime &valuetime, double y);
	void Reset();
//private:
	int		m_lNoValues;	// number values (used for array size)

};

//*******************************************************************************************************/
//* Class           : clPlot
//*
//* Base Class      : public CWnd
//*
//* Description     : Plot Component.
//*
//*					  This is a standard plot and can be used for any application.
//*
//*						1. A special 'autoscroll'mode exist for real time plots.
//*						2. Only a minimum of features are implemented.
//*						3. Series and legends are separated and must be set up individually.
//*						4. A set of defines (see top of file) are used to set the max array sizes.
//*						5. Only time are supported as x-axis.
//*						6. A large range of pre-calculated values are used for maximum speed.
//*
//* Author          : Jan Vidar Berger
//*******************************************************************************************************/
class AFX_EXT_CLASS clPlot : public CWnd
{
// Construction
public:
	clPlot( int timespan = 1 );	// timespan in minutes
//	clPlot(clPlot &plot);

	virtual ~clPlot();

// Attributes
public:
	int			m_nSpanTime;
//	bool		m_bReDraw;

	CRect		m_clientRect;		// actual controlled rect
	CRect		m_plotRect;			// clientRect - margins

	int			m_iMleft;			// left margin
	int			m_iMright;			// right margin
	int			m_iMtop;			// top margin
	int			m_iMbottom;			// bottom margin

	COLORREF	m_ctlBkColor;		// control background color
	COLORREF	m_gridColor;		// grid line color

	BOOL		m_bAutoScrollX;		// automatic x range scrolling, import

//	legend		m_pLegends[SERIENUMBER];

	serie		m_series[SERIENUMBER];	// 存放点位置

	timeaxis	m_timeaxis;			// bottom axis

	CFont		m_font;
	// 定义两种字体格式
	LOGFONT		m_logFont;
	LOGFONT		m_zoomFont;	// 默认字体, used in ComputeRects

	double		m_dzoom;
	int			m_TextHeight;	// 一个字符的高度

// Operations
public:
	BOOL		Create(DWORD dwstyle, CRect &rect, CWnd *pParent, UINT id);
	void		MoveWindow(CRect &Rect);

	void		ClearData();

	virtual void Draw(CDC * dc);			// Draw the entire plot
	virtual void DrawBasic(CDC * dc);		// Draw plot basics
	virtual void DrawPlot(CDC * dc);		// Draw the plot series
	virtual void DrawSerie(CDC *dc, int serie);
	virtual void DrawGrid(CDC * dc);		// Draw grids

	virtual void DrawYAxisGrid(CDC * dc);
	virtual void DrawXAxisGrid(CDC * dc);

	virtual void ComputeRects(BOOL bInitialize);

	virtual BOOL AddPoint(int serie, CTime &valuetime, double y);
	virtual void SetBXRange(CTime &fromtime, CTime &totime,BOOL bMove=TRUE);

	virtual void SetSerie(int s, int style, COLORREF color, 
		int minrange, int maxrange, const char *szTitle);
// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(clPlot)
	//}}AFX_VIRTUAL

// Implementation
public:
//	void SetRedraw( bool b );
//	clPlot& operator = ( clPlot &plot );

	// Generated message map functions
protected:
	//{{AFX_MSG(clPlot)
	afx_msg void OnPaint();
	//}}AFX_MSG
	BOOL clPlot::OnEraseBkgnd(CDC* pDC) ;
	DECLARE_MESSAGE_MAP()
private:
	void WriteLegend(CDC *dc, int s);
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_DQPLOT_H__0D536D37_5CF1_11D1_AED1_0060973A08A4__INCLUDED_)

⌨️ 快捷键说明

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