?? roundmeter.h
字號:
/***********************************************************************
* Copyright (c) 2007* All rights reserved.*
* ATTRIBUTE: 一個儀表控件類,用來仿真工業控制現場儀表數據顯示等
* FILE NAME: RoundMeter.h
* FILE ID: SYSTEMCTRL-ROUNDMETER-H
* ABSTRACT: 可用于工業控制仿真儀表數據顯示等
* CURRENT VERSION: V1.0
* AUTHOR: 戚高
* CONTECT: successq_g@163.com
* BUILD DATA: 26/12/2007
* COMPLETION DATE: 26/12/2007
* PRE-VERSION: NONE
* PRE-AUTHOR: NONE
* PRE-COMPLETION DATE:
* NOTE: 未經授權請不要作為商業用途,或者如果您要作為商業
用途,請聯系作者
***********************************************************************/
#ifndef __ROUNDMETER_H__
#define __ROUNDMETER_H__
#define MAXNAMELENGTH 99
#define PI 3.1415926
class CRoundMeter : public CStatic
{
public:
void SetTickColor(const COLORREF clTickColor,const COLORREF clSubTickColor);
void SetTextColor(const COLORREF clTextColor, const COLORREF clTextBackColor, const COLORREF clWarnTextColor, const COLORREF clWarnTextBackColor);
void SetFifthColor(const COLORREF clFifthColor,const COLORREF clFifthLineColor);
void SetFourthColor(const COLORREF clFourthColor,const COLORREF clFourthLineColor);
void SetThirdColor(const COLORREF clThirdColor,const COLORREF clThirdLineColor);
void SetSecondColor(const COLORREF clSecondColor,const COLORREF clSecondLineColor);
void SetFirstColor(const COLORREF clFirstColor,const COLORREF clFirstLineColor);
void SetNeedColor(const COLORREF clNeedColor,const COLORREF clNeedLineColor,const COLORREF clWarnNeedColor,const COLORREF clWarnNeedLineColor);
void SetAngle(int StartAngle, int EndAngle);
CRoundMeter();
virtual ~CRoundMeter();
void ReconstructControl();
void SetCurrentValue(const double dCurrentValue);
COLORREF GetMeterBackColor();
void SetMeterBackColor(const COLORREF clBackColor,const COLORREF clBackLineColor);
int GetTicks();
void SetTicks(const int nTicks);
int GetSubTicks();
void SetSubTicks(const int nSubTicks);
void SetRange(const double dMin, const double dMax,const double dWarnMin,const double dWarnMax);
char * GetUnits();
void SetUnits(const char *strUnits);
void SetMouseDrag(const bool bMouseDrag);
bool GetMouseDrag() const;
private:
virtual void PreSubclassWindow();
//繪制儀表背景
void DrawMeterBackground(CDC *pDC, CRect &rect);
void DrawNeedle(CDC *pDC, CRect &rect);
void DrawValue(CDC *pDC, CRect &rect);
double GetValue(double &dAngle);
double GetAngle(CPoint &ptCur);
protected:
//{{AFX_MSG(CRoundMeter)
afx_msg void OnPaint();
// afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
// afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
// afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
//圓直徑
void CalAboutTicks(int nRadius);
//返回遮蔽結果,圓中心,半徑,起始角,結束角
int CalVeilRgn(POINT* PtRgn,POINT PtCenter,int nRadius,int StartAngle, int EndAngle); //
//繪圖設備環境,區域點數組,數組點數,區域顏色
void DrawRgn(CDC *pDC,POINT *Rgn,int ptNum,COLORREF Fillcolor);
CRect m_rectCtrl; // 控件區域
CDC m_dcMeterPlate;
CBitmap m_bitmapMeterPlate;
CBitmap *m_pbitmapOldMeterPlate;
CPoint m_ptMeterCenter; // 儀表中心
int m_nRadiusFrame; // 儀表盤邊框
//從開始角度到結束角度順時針旋轉的圈,角度X軸右向為0度,逆時針為正
int m_nStartAngle; // 開始角度,不小于0,不大于360
int m_nEndAngle; // 結束角度,不小于0,不大于360
int m_ncnt; //遮蔽多邊形點數
//顏色相關變量
COLORREF m_NeedleColor; //指針顏色
COLORREF m_NeedleLineColor; //指針線色
COLORREF m_WarnNeedleColor; //報警指針顏色
COLORREF m_WarnNeedleLineColor; //報警指針線色
COLORREF m_FirstColor; //第一圈顏色
COLORREF m_FirstLineColor; //第一圈線色
COLORREF m_SecondColor; //第二圈顏色
COLORREF m_SecondLineColor; //第二圈線色
COLORREF m_ThirdColor; //第三圈顏色
COLORREF m_ThirdLineColor; //第三圈線色
COLORREF m_FourthColor; //第四圈顏色 指針圈1
COLORREF m_FourthLineColor; //第四圈線色 指針圈1
COLORREF m_FifthColor; //第五圈顏色 指針圈2
COLORREF m_FifthLineColor; //第五圈線色 指針圈2
COLORREF m_TextColor; //普通字體顏色
COLORREF m_TextBackColor; //普通字體底色
COLORREF m_WarnTextColor; //報警字體顏色
COLORREF m_WarnTextBackColor; //報警字體底色
COLORREF m_BackColor; //最外方框顏色
COLORREF m_BackLineColor; //最外方框線色
COLORREF m_TickColor; //大格刻度顏色
COLORREF m_SubTickColor; //小格刻度顏色
double m_dMaxValue; //表量程初始值
double m_dMinValue; //表量程終值
double m_WarnMaxValue; //報警上限
double m_WarnMinValue; //報警下限
int m_nTicks; //大格個數
int m_nSubTicks; //大格中小格個數
CArray<CPoint,CPoint> m_TicksSPt; //大格起始點
CArray<CPoint,CPoint> m_TicksEPt; //大格終止點
CArray<CRect,CRect> m_TicksTitle; //寫刻度的矩形
CArray<CPoint,CPoint> m_SubTicksSPt; //小格起始點
CArray<CPoint,CPoint> m_SubTicksEPt; //小格終止點
CRect m_nrectUnits; //表單位矩形
CRect m_nrectValue; //Value顯示的矩形
char m_strUnits[MAXNAMELENGTH + 1]; //表單位
double m_dCurrentValue; //當前值
bool m_bMouseDrag; //是否允許鼠標拖動
BOOL m_bReset; //是否重新計算繪圖相關變量
};
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -