In the third lesson, I am stupid to show you the function of using CChart to draw a contour map. I have implemented a contour map with very little code.
This course uses the cloud map function of CChart to change the contour map of Lesson 3 to a cloud map.
Follow the method in the first lesson to create a VC6 project Lesson13.
Create a cloud map field function before the WndProc function in the Lesson13.cpp file. Select the same function as the function in Lesson 3.
double f(double x, double y){return 1.0/((x-1.0)*(x-1.0)+y*y+1.0);}
Modify the response function of WM_CREATE as follows.
Case WM_CREATE: chartWnd. attach (hWnd, ktype1_map); chartWnd. getChart ()-> SetFieldFcn (f); {double xRange [2], yRange [2]; xRange [0] =-2.0; xRange [1] = 2.0; yRange [0] =-2.0; yRange [1] = 2.0; chartWnd. getChart ()-> SetPlotRange (xRange, yRange);} chartWnd. getChart ()-> SetTitle (_ T ("test cloud map"); break;
The code here is familiar.
It is easy to find that, compared with the code in the third lesson, except for the last line of the title, there is only a change in the first sentence. The ktype1_line is changed to ktype1_map, and the latter is the code of the cloud map.
Run the program.
650) this. width = 650; "src =" http://img.blog.csdn.net/20130919125707421? Watermark/2/text/plain =/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA =/dissolve/70/gravity/SouthEast "alt =" SouthEast "/>
The color of the cloud map is gorgeous, and the effect is indeed better than that of the contour map.
The legend of the cloud map is different from that seen in the previous course. This is a gradient color.
Next, let's modify the cloud map field function so that it has two maximum values to see if the CChart result is correct.
double f(double x, double y){return 1.0/((x-1.0)*(x-1.0)+y*y+1.0) + 1.0/((x+1.0)*(x+1.0)+y*y+1.0);}
Running effect.
650) this. width = 650; "src =" http://img.blog.csdn.net/20130919130018765? Watermark/2/text/plain =/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA =/dissolve/70/gravity/SouthEast "alt =" SouthEast "/>
As we expected, the current image has two maximum points.
This lesson introduces the cloud map function of CChart. The cloud maps and the contour maps described above have their own characteristics. In fact, dumb also implements a view that combines the contour map with the cloud map. Of course, this is perfect. This new view is not detailed here.