VS2010 using TeeChart5 's colorgrid to draw a one-dimensional distance image

Source: Internet
Author: User

Draw a one-dimensional distance principle: Use the Colorgrid display (x, y, z) in the Teechart control to represent the x-axis and y-axis data for one-dimensional distance images, and y for the corresponding values, displayed in different colors.

1. Register TEECHART5

For WIN XP and 32 systems, copy Teechart5.ocx to C:\windows\system32,win+r, enter cmd, open command prompt, enter Regsvr32.exe C:\Windows\System32\ Teechart5.ocx can be;

For Win7 64-bit systems, copy Teechart5.ocx to C:\Windows\SysWOW64, Run command prompt as administrator, enter Regsvr32.exe C:\Windows\SysWOW64\TeeChart5.ocx To

2.VS adding Teechart controls

2.1 Create an MFC project, in the VS Resource view, select a dialog, right-click in the dialog, select "Insert ActiveX Control" in the Pop-up dialog box, select Teechart Pro ActiveX Contorl v5, OK.

2.2 Set the inserted Teechart control, double-click, add Series in the popup dialog box, select Colorgrid, set the series property, set the Colorrange in grid, start with red, terminate to blue, middle color green, OK;

2.3 Right-click on the Teechart control and select "Add Variable", such as M_tchart, to determine

2.4 Add other classes in Teechart, such as cseries,ccolorgridseries, in the Solution Selection project, right-click "Add", "TypeLib MFC Class", in the popup dialog select "Registry", in the Available type library select " Teechart Pro ActiveX contorl v5<1.0> ", select the class to add on the interface. The commonly used classes are iaix,iaxe,iseries (and other types of series, data in charts), Iexport (export, Xxxexport), Ilegend (Legend of data series), Izoom (zoom), etc.

2.5 delete "M_tchart (0)" In the MFC class constructor.

3. Using Colorgrid

3.1 Use ADDARRAYXYZ to quickly add data, using the Colorgrid example:

voidCmfcdemodlg::createcolorgrid () {//Image ColorgridCOleSafeArray XX;//the horizontal axis of a color gridCOleSafeArray ZZ;//the ordinate of the color grid is the same as our usual YCOleSafeArray YY;//represents the value of a color, not the y-axisDWORD numelements = the*2;//Data LengthXx. Create (VT_I4,1,&numelements); Yy. Create (VT_I4,1,&numelements); Zz. Create (VT_I4,1,&numelements); intxidx=0, yidx=0; LongI=0;  for(xidx=0;xidx<2; xidx++)    {         for(yidx=0;yidx< the; yidx++)        {            Doubleval = rand ()% -;//values for two-dimensional arraysYy. Putelement (&i,&val); Xx. Putelement (&i,&xidx); Zz. Putelement (&i,&yidx); I++; }} ((Ccolorgridseries) ((CSeries) M_tchart. Series (0) . Get_ascolorgrid ()). ADDARRAYXYZ (XX,YY,ZZ);//Type conversion}

3.2 Implementing a one-dimensional distance image example

First define a one-dimensional distance-like structure:

struct stru_hrrp{    int fftlen;   FFT length    int datalen;   Data Array length    double *time;   Time[datalen], one-dimensional distance like the time array    double *lc;   Lc[fftlen], one-dimensional distance like a ruler array    double **HRRP;   Hrrp[datalen][fftlen] HRRP data, two-dimensional array }STRU_HRRP;

Drawing code (add Teechart See 2.1-2.5, the following is created by code Colorgrid, you can omit step 2.2):

voidCreatehrrpgraph (stru_hrrp&HRRP) {M_tchart.    Clearchart (); M_tchart. Addseries (Sccolorgrid);//Create ColorgridCcolorgridseries Series= ((Ccolorgridseries) ((CSeries) M_tchart. Series (0) . Get_ascolorgrid ()); Series.put_usecolorrange (TRUE);//Set ColorrangeSeries.put_startcolor (RGB (255,0,0)); Series.put_midcolor (RGB (0,255,0)); Series.put_endcolor (RGB (0,0,255)); ((Clegend) m_tchart.get_legend ()). Put_visible (TRUE);//legend Display Data color intensityCOleSafeArray XX;//the horizontal axis of a color gridCOleSafeArray ZZ;//the ordinate of the color grid is the same as our usual YCOleSafeArray YY;//represents the value of a color, not the y-axisDWORD numelements = HRRP. Datalen *HRRP.    Fftlen; Xx. Create (VT_R8,1,&numelements); Yy. Create (VT_R8,1,&numelements); Zz. Create (VT_R8,1,&numelements); intxidx=0, yidx=0; LongI=0;  for(xidx=0; XIDX&LT;HRRP. datalen;xidx++)    {         for(yidx=0; YIDX&LT;HRRP. fftlen;yidx++)        {            DoubleXval =HRRP.            LC[YIDX]; DoubleYval =HRRP.            HRRP[XIDX][YIDX]; DoubleZval =HRRP.            TIME[XIDX]; Xx. Putelement (&i,&xval); Yy. Putelement (&i,&yval); Zz. Putelement (&i,&zval); I++; }} series. ADDARRAYXYZ (XX,YY,ZZ);}

done!

This article simply introduces the teechart of using Colorgrid to draw a one-dimensional distance image, if there is a problem, but also to correct.

VS2010 using TeeChart5 's colorgrid to draw a one-dimensional distance image

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.