A picture class, similar MS

zhaozj2021-02-16  36

Continue. The following is the implementation of the class. In order to eliminate the flashing of the screen, the way of bitmap is used. When making a picture, the characteristics of numerical analysis are taken into account, do three points:

(1) Automatically adjust the grid line to ensure that the data display is within the region (ii) If a zero value occurs, make sure that the appearance of the 0 value grid line (3) automatically adjusts the display mode of the value, ensuring the horizontal axis The display is therefore a very suitable graphic display that is very suitable for numerical analysis. Of course, because of the way you use a bitmap map, you can use it to make real-time draw .lyhlinechart.h: header file ****** The File word in the article is generated when paste, please delete ********

#if! defined (AFX_LYHLINECHART_H__9269BA72_F2CB_4D4D_9EF8_624E8FA939BD__INCLUDED _) # Define AFX_LYHLINECHART_H__9269BA72_F2CB_4D4D_9EF8_624E8FA939BD__included_

#i_msc_ver> 1000 # pragma overce # Endif // lyhlinechart.h: header file // # include struct datatru {double x; double y;}; typedef clist CItemData; class CLineChartItem: public CObject {public: CLineChartItem () {legendcolor = RGB (0,0,128); iWidth = 1; iStyle = PS_SOLID;}; virtual ~ CLineChartItem () {if (m_data.GetCount ()> 0) m_data .Removeall ();}; citemdata m_data; // coordinate data colorref m_colorline; // Line color cstring m_legenD; // Line instructions, text content displayed in the legend ColorRef LegendColor; int oilth, iStyle; // Line width, line type};

Typedef CTypedPtrarray CITEMARRAY

Class ClyhlineChartSet: PUBLIC COBJECT {public: Uint RightSpace; File: / / Table Right to the Right Down; File: // The space of the coordinate value and the table line Du uT VLINENUM; // Y-axis direction Number UINT HLINENUM; // X-axis direction The number of grid lines BOOL buborder; // Whether to display the external border uint borderwidth; bool bxinborder; / / Show the interior of the coordinate line, Bool Byinborder; // Display the interior of the coordinate line Line, ColorRef BorderColor; // Border Color ColorRef InborderColor; // Coordinate Color ColorRef Bkcolor; // Background Color CString Xtitle; // X Title Content CString Ytitle; // Y Title Content CString Title; // Title Content CString Footnote; // Footnotes ColorRef XtileColor; // x Title Color ColorRef YtileColor; // Y Title Color ColorRef TileColor; // Title Color ColorRef FootColor; // Footnot Color ColorRef AxiedNumColor; Bool Blegend; // Whether the legend, legend content storage The Bool AutoRange in the drawing data is selected. ) {// default setting RightSpace = 5; charspace = 2; VLINENUM = 10; borderwidth = 1; borderwidth = 1; bborder = true; byinborder = true; bordercolor = rgb (0, 0); InborderColor = RGB (0,0,0); XtileColor = RGB (0, 0, 128); YtileColor = RGB (0, 0, 128); TIL Ecolor = RGB (0,0,255); footcolor = RGB (0,0,0); BLEGEND = false; xmax = 100.0; ymax = 100.0; xmin = 0.0; ymin = 0.0; autorance = true; bkcolor = RGB (150, 150, 150) Xtitle = "x title"; ytitle = "y title"; title = "Title"; FootNote = "foot text"; fontsize = 16; fontname = "kaiti"; axiednumcolor = RGB (0, 0, 0); bStretch = false;}}; /// CLyhLineChart window # define NODATA 1.7E300 // no data identifying the data point #define DEFAULTCOLOR RGB (150,150,150) class CLyhLineChart: public CWnd {// Constructionpublic: CLyhLineChart ();

// attributespublic: CItemRay m_items; // Operationspublic:

// Overrides // ClassWizard Generated Virtual Function Overrides file: // {{AFX_VIRTUAL (CLYHLINECHART) FILE: / /}} AFX_VIRTUAL

// Implementationpublic: void SetAxiedColor (COLORREF crColor); void SetPicFont (int fontsize, CString fontname); COLORREF SetBkColor (COLORREF crColor); void ShowYGrid (BOOL bSign = TRUE); // Display y axied grid line void ShowXGrid (BOOL bSign = True); // Display X Axied Grid Line Int SetyDiVision; // SET Y AXIED MAX DIVISION INT SetXDivision; Int getLinenum (); // Get The Total Num of Line In Chart INT GetIndex (CString CSLGEND); // Returns the index corresponding to the graphical name, -1 indicates that the legend does not exist void deleteLine (INT NINDEX = 1); / / Delete Nindex correspondence, the index will change the void setlegend (CSTRING CSLGEND, INT NINDEX = 1 , COLORREF crColor = DEFAULTCOLOR); BOOL ShowLegeng (BOOL bShow = TRUE); CString SetFootNote (CString csFootNote, COLORREF crColor = DEFAULTCOLOR); CString SetXTitle (CString csXTitle, COLORREF crColor = DEFAULTCOLOR); CString SetYTitle (CString csYTitle, COLORREF crColor = DEFAULTCOLOR ); Colorref gettitle; void settitle (CString cstitle = (lpctstr) null, colorref crcolor = defaultColor); // Set the title, do not display Void SetLineStyle when NULL (int NStyle, int NWIDTH, ColorRef crColor, int namex = 1); int addressdata (int NINDEX = 1); // Set intermittent, call int Batchadddata (double * x, double * y, int ncount, int nindex = 1); int NCOUNT Adddata (Double X, Double Y, INT lineIndex = 1); // LineIndex is the line number int CalDecnum (Double Minnum, Double MaxNum, CString & Data); // Return value is a decimal point number, file: // string is stored String void refresh (); Bool SetAutoRange (Bool Bauto = 0.0, Double Maxx = 0.0, Double Maxx = 0.0, Double Maxy = 100.0); // Setting Bool AddLinetoChart (ColorRef color = default); Bool RegisterWndClass (Hinstance Hinstance); Virtual ~ Clyhlinechart ();

// Generated message map functionsprotected: void DrawPic (); CDC m_MemDC; CBitmap m_Bitmap; file: // {{AFX_MSG (CLyhLineChart) afx_msg void OnPaint (); afx_msg void OnSize (UINT nType, int cx, int cy); file: //}} AFX_MSG DECLARE_MESSAGE_MAP () private: void CalRange (); ClyhlineChartSet M_Set;};

File: // {{AFX_INSERT_LOCATION}} // Microsoft Visual C Will Insert Additional Declarations Immediately Before The Previous Line.

#ndif //! defined (AFX_LYHLINECHART_H__9269BA72_F2CB_4D4D_9EF8_624E8FA939BD__INCLUDED_)

Full text.

转载请注明原文地址:https://www.9cbs.com/read-22079.html

New Post(0)