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

📄 multicolorplotbtn.h

📁 实时存储 "实时 "显示的功能.具体就是: 从机器的pci板子获得采集的数据,这些数据要实时保存到机器的阵列硬盘上 同时想在采集的过程中显示一下数据的波形. ////采集板的数据来到计算机内存
💻 H
字号:
////////////////////////////////////  MulticolorPlotBtn.h ////////////////////////////////////

/*
模块名称:MulticolorPlotBtn.h
版    本:0.1 Alpha
版    权:Copyright (C) 2005 wlzqin
模块功能:动态图表显示数据
作    者:wlzqi
作者邮箱:mailto:wlzqin@3stonesoft.com
建立时间:22005年6月14日  乙酉 鸡年五月初八
最后修改:by wlzqi
修改历程:
注意事项:
备  注:支持 UNICODE 和 ANSI 编码
  :测试平台 Windows 2000、IE6、Direcx9、 AMD Xp 2000 + CPU
  :不兼容 Windows 98
功能简介:动态实时显示数据,显示方式有BAR和LINE(其它方式以后添加)
    ,可动态实时改变曲线属性。支持任意范围数据,可设定范围,
    也可不设定显示范围(自动寻找最符合的范围),还可任意锁定
    (自由)范围。支持浮点数。
*/

#pragma once
#include "afxwin.h"
#include <math.h>

#define BAR    0
#define LINE   1

class CMulticolorPlotBtn :
 public CButton
{
public:
 CMulticolorPlotBtn(void) ;
 virtual ~CMulticolorPlotBtn(void);

private:    // 公共属性
 int nPlotType ;  // 曲线类型  BAR 或 LINE    // BAR
 bool bfInit ;  // 是否初始化       // false
 // 网格X方向上的间距
 int nGridResolutionX ;          // 10
 // 网格Y方向上的间距
 int nGridResolutionY ;          // 10
 // 网格滚动的速度和方向(正值为从左向右滚动和从上到下,否则反之。0不动)
 int nGridScrollSpeedX ;          // -1
 int nGridScrollSpeedY ;          // 0
 // 数据点分辨率大小(即:一个数据点占据的像素数)
 int nPlotGranulatrity ;          // 2
 // 网格线宽度
 int nGridLineWidth ;          // 1
 // 背景色
 COLORREF m_clrDarkBack ;         // RGB(0,0,75)
 // 前景色
 COLORREF m_clrDarkLine ;         // RGB(32,64,32)
 // 控件矩形
 RECT m_rect ;
 // 控件的尺寸
 CSize m_Size ;
 // 控件可容纳可见的数据点数
 int nPlotData ;            // 0
 // 实际数据
 float * pfData ;           // 0
 // 数据范围
 float fLow , fHigh ;          // 0,0
 // 数据比例
 float fScaleY ;            // 1.0
 // 数据点处的颜色
 COLORREF m_clrCyanData ;         // RGB ( 0,255,255 )
 // 画笔
 CPen m_GridPen ;
 // 数据点位图画刷
 CBrush m_clrBrush ;
 // 网格开始位置
 int nGridStarPosX , nGridStarPosY ;       // 0,0
 // 锁定显示范围
 bool bLock ;            // true---锁定
 // 控件上显示的字体
 CFont m_SmallFont ;
 // Y轴刻度的颜色
 COLORREF m_clrAxisScaleY ;         // RGB ( 0,255,255 )
 // 是否显示Y轴刻度数字
 int nShowFormatDataText ;         // 0---不显示
 // 控件标题
 TCHAR szTitls [MAX_PATH * sizeof ( TCHAR ) + 1] ;   // NULL
 // 曲线单位
 TCHAR szUints [32 * sizeof ( TCHAR ) + 1] ;     // NULL
private:
 // 关键代码
 CRITICAL_SECTION  g_cs ;
public:    // 公共方法
 // 设置画线的类型
 void SetPlotType ( int nType )
 {
  nPlotType = nType ;

  bfInit = false ;
 }
 // 设置网格间距
 void SetGridResolutionX ( int nGridReluX ) { nGridResolutionX = nGridReluX ; }
 void SetGridResolutionY ( int nGridReluY ) { nGridResolutionY = nGridReluY ; }
 // 设置网格滚动速度
 // 正值为从左向右滚动,0不动
 void SetGridScrollSpeedX ( int nSpeedX ) { nGridScrollSpeedX = nSpeedX ; }
 // 正值为从上到下滚动,0不动
 void SetGridScrollSpeedY ( int nSpeedY ) { nGridScrollSpeedY = nSpeedY ; }
 // 数据点面积大小(即:一个数据点占据的像素数)
 bool SetPlotGranulatrity ( int nPlotGrltiy )
 {
  nPlotGranulatrity = nPlotGrltiy ;
  nPlotData = m_Size.cx / nPlotGranulatrity ;
  pfData = new float [ nPlotData ] ;
  if ( pfData )
  {
   // 初始化数据为 0
   ZeroMemory ( pfData , sizeof ( pfData ) * nPlotData ) ;

   return true ;
  }

  return true ;
 }
 // 网格线宽度
 void SetGridLineWidth ( int nWidth ) { nGridLineWidth = nWidth ; }
 // 背景色
 void SetGridBackClr ( COLORREF clr ) { m_clrDarkBack = clr ; }
 // 前景色
 void SetGridLineClr ( COLORREF clr )
 {
  m_clrDarkLine = clr  ;
  m_GridPen.CreatePen ( PS_SOLID , nGridLineWidth , m_clrDarkLine ) ;

  m_clrDarkLine = clr ;
 }
 // 数据范围
 void SetRang ( float fL , float fH )
 {
  fLow = fL ;
  fHigh = fH ;
 }
 // 创建画笔
 void SetLinePen ( int nWidth , COLORREF clr )
 {
  nGridLineWidth = nWidth ;
  m_clrDarkLine = clr  ;
  m_GridPen.CreatePen ( PS_SOLID , nGridLineWidth , m_clrDarkLine ) ;
 }
 // 锁定数据显示范围
 void LockRang ( bool bfLock = true ) ;
 void LockRang ( float fMin = 0.0 , float fMax = 100.0 ) ;
 // Y轴刻度颜色,bfShow==0显示刻度数字,1仅在左上角显示1000(k/sec)/2000样子的数字,2显示最大最小,3显示全部
 void SetAxisScaleClrY ( COLORREF clr = RGB ( 0 , 255 , 255 ) )
 {

  m_clrAxisScaleY = clr ;
 }
 // 标题
 void SetTitle ( PCTSTR pctTitle = NULL )
 {
  _stprintf ( szTitls , _TEXT ( "%s" ) , pctTitle ) ;
 }
 // 数据单位例:SetUnit( _TEXT ( "(k/sec)" ) ) ;
 void SetUnit ( PCTSTR pctUint = NULL )
 {
  _stprintf ( szUints , _TEXT ( "%s" ) , pctUint ) ;
 }
 // 是否显示数据标题、颜色、单位
 /*
 nShow = 0 ; 不显示任何文本
 nShow = 1 ; 仅仅显示标题
 nShow = 2 ; 仅仅显示标题和流量总计
 nShow = 3 ; 显示标题和最小值
 nShow = 4 ; 显示标题、最小值和中值
 */
 void ShowTitle ( int nShow = 1 )
 {
  nShowFormatDataText = nShow ;
 }
private:    // BAR属性
 // BAR颜色
 COLORREF m_clrUp ;
 COLORREF m_clrDown ;
public:     // BAR方法
 // BAR 颜色
 // clrUp  -------- 顶部颜色
 // clrDown  -------- 底部颜色
 // bfRfastness  -------- 红色分量是否固定不变  false ---- 渐变
 // bfGfastness  -------- 红色分量是否固定不变  false ---- 渐变
 // bfBfastness  -------- 红色分量是否固定不变  false ---- 渐变
 void SetBarColor ( COLORREF clrUp , COLORREF clrDown , bool bfRfastness = false , bool bfGfastness = false , bool bfBfastness = false ) ;
 // 设置数据
 void SetData ( float fData ) ;
private:    // LINE属性
 // 曲线颜色
 COLORREF m_clrLinePen ;     // RGB(0,255,0)
 // 曲线宽度
 int nLineWidth ;
public:     // LINE方法
 // 曲线颜色
 void SetLineColorWidth ( COLORREF clrLine = RGB ( 0 , 255 , 0 ) , int nWidth = 1 )
 {
  nLineWidth  = nWidth ;
  m_clrLinePen = clrLine ;
 }
 void SetLineColor ( COLORREF clrLine = RGB ( 0 , 255 , 0 ) ) { m_clrLinePen = clrLine ; }
 void SetLineWidth ( int nWidth = 1 ) { nLineWidth = nWidth ; }
 const COLORREF GetLineColor () { return m_clrLinePen ; }
 const int GetLineWidth () { return nLineWidth ; }
public:
 DECLARE_MESSAGE_MAP()
 afx_msg void OnTimer(UINT nIDEvent);
protected:
 virtual void PreSubclassWindow();
public:
 virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
};

////////////////////////////////////  end ////////////////////////////////////

⌨️ 快捷键说明

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