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

📄 spectrumanalyzer.h

📁 一个组太软件中
💻 H
字号:
#if !defined(AFX_SPECTRUMANALYZER_H__391E5E28_138F_4AB3_A06B_4140B02120B8__INCLUDED_)
#define AFX_SPECTRUMANALYZER_H__391E5E28_138F_4AB3_A06B_4140B02120B8__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "AfxTempl.h"

// SpectrumAnalyzer.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CSpectrumAnalyzer window

class CSpectrumAnalyzer : public CWnd
{
// Construction
public:
	CSpectrumAnalyzer();


public:
	BOOL Create(const RECT &rect, CWnd *pParentWnd, UINT uID, CPoint XRange, CPoint YRange);
	BOOL Destroy();
	void DrawText(CPoint Pos, CString szStr);
	void Clear();
	void UpdateLabels();
	void ClearList();
	CPoint GetRangeX() const { return m_RangeX;};
	void SetCallbackSetToFreq(HWND hWnd, UINT nMessage, WPARAM wParam = 0, LPARAM lParam = 0);
	void SetCallbackShowFreq(HWND hWnd, UINT nMessage, WPARAM wParam = 0, LPARAM lParam = 0);
	void SendCallback(int iCallbackIndex, WPARAM wParam, LPARAM lParam);
	BOOL HasValidWin() { return (m_pMemDC!=NULL);};
	
	void ReSetStep(BOOL bDoZoomOut = TRUE);

	BOOL InvalidateCtrl();
	void AddPoint(CPoint CurPos);
	POSITION GoToFirstPoint() { return m_pList->GetHeadPosition(); }
	CPoint GetNextPoint(POSITION &NewPos);
	int GetPointCount() { return m_pList->GetCount();}
	virtual ~CSpectrumAnalyzer();
	void DrawLine();
	void SetVHighIndicator(int iVHighIndicator); 
	
	// Top-Left point in View scale, used for scrolling and determining if a point is viewable!
	CPoint m_ViewTopLeft;
	
	// Client Window size, width and height
	CRect m_rcClient;
	int m_iClientWidth, m_iClientHeight;
	
// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CSpectrumAnalyzer)
	//}}AFX_VIRTUAL

	
	// Generated message map functions
protected:
	//{{AFX_MSG(CSpectrumAnalyzer)
	afx_msg void OnPaint();
	afx_msg void OnLButtonDown( UINT, CPoint );
	afx_msg void OnHScroll( UINT nSBCode, UINT nPos, CScrollBar* pScrollBar );
	afx_msg void OnMouseMove( UINT nFlags, CPoint point );
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

#pragma pack(1)
	typedef struct _STRUCT_CALLBACK
	{
		HWND		hWnd;			// Handle to window
		UINT		nMessage;		// Message identifier
		WPARAM		wParam;
		LPARAM		lParam;
	} STRUCT_CALLBACK;
#pragma pack()

	STRUCT_CALLBACK m_csCallbackSetToFreq,
					m_csCallbackShowFreq;
					

private:

	// Range of input values, X and Y Axes
	// x is for lower bound, y for upper bound
	CPoint m_RangeX, m_RangeY;  

	// an Indicator of HIGH region, high region points are drawn by the pen m_IndicatorPen
	int m_iVHighIndicator,
		m_iVHighIndicatorView;
	
	// the scales to map Axis to View, vice versa
	double m_fHViewScale, m_fVViewScale;
	
	// number of grid lines to be drawn
	int m_iNumVGridLines, m_iNumHGridLines;
	
	// Scroll Bar variables
	int m_iHScrollPos;  // Horizontal scroll position
    int m_iHScrollShift;// Horizontal Scroll shift amount
	
	CPoint MapPointToAxis(const CPoint pos);
	CPoint MapAxisToPoint(const CPoint pos);
	BOOL MapAxisToView(CPoint &pos);
	CPoint MapViewToAxis(const CPoint pos);
	void SetRangeY(const CPoint RangeY);
	void SetRangeX(const CPoint RangeX);
	BYTE GetPairOfPoints(CPoint &pt1, CPoint &pt2, POSITION &pos);
	void DrawPieceOfLine(CPoint ptStart, CPoint ptEnd);
	
	void HorizScroll(BOOL bIfToLeft = FALSE, int iScrollAmount = 0);
	

	// these are the scales that map Point to Axis, and vice versa
	double m_fHAxisScale, m_fVAxisScale;
	
	// margins for drawing grid and etc in the control
	int m_iTopMargin, 
		m_iBotMargin, 
		m_iLeftMargin, 
		m_iRightMargin;
	
	CDC *m_pMemDC;

	// Pen, Font and Width of them to draw
	CPen m_DrawPen;
	CPen m_IndicatorPen;
	CFont m_TextFont;
	int m_iDrawPenWidth;

	// Colors
	COLORREF m_crBackGround,
		m_crGrids,
		m_crText,
		m_crDrawPen,
		m_crIndicatorPen;
	
	// List of points for drawing
	CList<CPoint, CPoint&> *m_pList;
	
	// Maximum viewable pixel, which is reached by scrolling
	int m_iMaxHAxis, m_iMaxVAxis;	

	// Spacing between grid lines; this is for best resolution (dippest zoom-in)
	DWORD m_iVLabelSpacing,	m_iHLabelSpacing;

	DWORD m_iHLabelValueScale; // used for scaling labels of horizontal axis
	DWORD m_iHLabelDistance; // place hor. labels each (for example) 5 vertical lines

};

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

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_SPECTRUMANALYZER_H__391E5E28_138F_4AB3_A06B_4140B02120B8__INCLUDED_)

⌨️ 快捷键说明

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