?? clplot.h
字號:
//*******************************************************************************************************/
//* FileName : clPlot.h
//* Description : Real Time Plot for MFC
//* Contents: : timeaxis time axis 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, 每格最多兩個數(shù)據(jù)
#define COORWIDTH 35 // 每個坐標(biāo)數(shù)值的寬度
//*******************************************************************************************************/
//* simple data value struct. used in dynamic array
//*******************************************************************************************************/
typedef struct _value
{
double dValue;
CTime ValueTime;
}value;
//*******************************************************************************************************/
//* 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; //時間間隔(秒)/畫圖區(qū)寬度
timeaxis()
{
m_szTitle = "Time";
m_mintime = 0;
m_maxtime = 600;
m_iTimeMode = 0;
m_dSecondsPrPixel = 1;
}
};
/*******************************************************************************************************
//* data serie
改進(jìn)的循環(huán)隊列, 元素個數(shù)為 #define MAXSIRIEDATA 140 個,
開始時, m_lbegin == m_lend
訪問數(shù)據(jù)時, 若 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.
//*
//* Author : Jan Vidar Berger
//* Modified by : Bill chen
//*******************************************************************************************************/
class AFX_EXT_CLASS clPlot : public CWnd
{
// Construction
public:
clPlot( int timespan = 1 ); // timespan in minutes
virtual ~clPlot();
// Attributes
public:
int m_nSpanTime;
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
serie m_series[SERIENUMBER]; // 存放點位置
timeaxis m_timeaxis; // bottom axis
CFont m_font;
// 定義兩種字體格式
LOGFONT m_logFont;
LOGFONT m_zoomFont; // 默認(rèn)字體, 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:
// 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_)
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -