Click here to Skip to main content
15,860,861 members
Articles / Desktop Programming / MFC

High-speed Charting Control

Rate me:
Please Sign up or sign in to vote.
4.95/5 (327 votes)
13 Jul 2010CPOL35 min read 4.1M   99.5K   787  
A flexible charting control to display 2D data
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>ChartDemo: E:/Sources Misc/ChartDemo/ChartCtrl/ChartXYSerie.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
    </ul>
  </div>
<h1>E:/Sources Misc/ChartDemo/ChartCtrl/ChartXYSerie.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> *</span>
<a name="l00003"></a>00003 <span class="comment"> *      ChartXYSerie.h</span>
<a name="l00004"></a>00004 <span class="comment"> *</span>
<a name="l00005"></a>00005 <span class="comment"> *      Written by C�dric Moonen (cedric_moonen@hotmail.com)</span>
<a name="l00006"></a>00006 <span class="comment"> *</span>
<a name="l00007"></a>00007 <span class="comment"> *</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> *      This code may be used for any non-commercial and commercial purposes in a compiled form.</span>
<a name="l00010"></a>00010 <span class="comment"> *      The code may be redistributed as long as it remains unmodified and providing that the </span>
<a name="l00011"></a>00011 <span class="comment"> *      author name and this disclaimer remain intact. The sources can be modified WITH the author </span>
<a name="l00012"></a>00012 <span class="comment"> *      consent only.</span>
<a name="l00013"></a>00013 <span class="comment"> *      </span>
<a name="l00014"></a>00014 <span class="comment"> *      This code is provided without any garanties. I cannot be held responsible for the damage or</span>
<a name="l00015"></a>00015 <span class="comment"> *      the loss of time it causes. Use it at your own risks</span>
<a name="l00016"></a>00016 <span class="comment"> *</span>
<a name="l00017"></a>00017 <span class="comment"> *      An e-mail to notify me that you are using this code is appreciated also.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> *</span>
<a name="l00020"></a>00020 <span class="comment"> */</span>
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 <span class="preprocessor">#pragma once</span>
<a name="l00023"></a>00023 <span class="preprocessor"></span><span class="preprocessor">#include "ChartSerieBase.h"</span>
<a name="l00024"></a>00024 
<a name="l00026"></a><a class="code" href="struct_s_chart_x_y_point.html">00026</a> <span class="keyword">struct </span><a class="code" href="struct_s_chart_x_y_point.html" title="Structure containing a point data with X and Y values.">SChartXYPoint</a>
<a name="l00027"></a>00027 {
<a name="l00028"></a>00028         <a class="code" href="struct_s_chart_x_y_point.html" title="Structure containing a point data with X and Y values.">SChartXYPoint</a>() : <a class="code" href="struct_s_chart_x_y_point.html#2aa25d52c4928b5adf4f1b73896b2c24" title="The point X value.">X</a>(0.0), <a class="code" href="struct_s_chart_x_y_point.html#cde5375a37a5b3b153c2693dbf56fed6" title="The point Y value.">Y</a>(0.0)  
<a name="l00029"></a>00029         { 
<a name="l00030"></a>00030 <span class="preprocessor">                #ifndef NO_USER_DATA</span>
<a name="l00031"></a>00031 <span class="preprocessor"></span>                <a class="code" href="struct_s_chart_x_y_point.html#13f11dcf58dbe5317026ed9d919b3217" title="Optional user data.">pUserData</a> = NULL;
<a name="l00032"></a>00032 <span class="preprocessor">                #endif</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span>        }
<a name="l00034"></a>00034         <a class="code" href="struct_s_chart_x_y_point.html" title="Structure containing a point data with X and Y values.">SChartXYPoint</a>(<span class="keywordtype">double</span> XVal, <span class="keywordtype">double</span> YVal) : <a class="code" href="struct_s_chart_x_y_point.html#2aa25d52c4928b5adf4f1b73896b2c24" title="The point X value.">X</a>(XVal), <a class="code" href="struct_s_chart_x_y_point.html#cde5375a37a5b3b153c2693dbf56fed6" title="The point Y value.">Y</a>(YVal)  
<a name="l00035"></a>00035         { 
<a name="l00036"></a>00036 <span class="preprocessor">                #ifndef NO_USER_DATA</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span>                <a class="code" href="struct_s_chart_x_y_point.html#13f11dcf58dbe5317026ed9d919b3217" title="Optional user data.">pUserData</a> = NULL;
<a name="l00038"></a>00038 <span class="preprocessor">                #endif</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span>        }
<a name="l00040"></a>00040 
<a name="l00041"></a>00041         <span class="keywordtype">double</span> GetX()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="struct_s_chart_x_y_point.html#2aa25d52c4928b5adf4f1b73896b2c24" title="The point X value.">X</a>; }
<a name="l00042"></a>00042         <span class="keywordtype">double</span> GetY()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="struct_s_chart_x_y_point.html#cde5375a37a5b3b153c2693dbf56fed6" title="The point Y value.">Y</a>; }
<a name="l00043"></a>00043         <span class="keywordtype">double</span> GetXMin()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="struct_s_chart_x_y_point.html#2aa25d52c4928b5adf4f1b73896b2c24" title="The point X value.">X</a>; }
<a name="l00044"></a>00044         <span class="keywordtype">double</span> GetXMax()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="struct_s_chart_x_y_point.html#2aa25d52c4928b5adf4f1b73896b2c24" title="The point X value.">X</a>; }
<a name="l00045"></a>00045         <span class="keywordtype">double</span> GetYMin()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="struct_s_chart_x_y_point.html#cde5375a37a5b3b153c2693dbf56fed6" title="The point Y value.">Y</a>; }
<a name="l00046"></a>00046         <span class="keywordtype">double</span> GetYMax()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="struct_s_chart_x_y_point.html#cde5375a37a5b3b153c2693dbf56fed6" title="The point Y value.">Y</a>; }
<a name="l00047"></a>00047 
<a name="l00049"></a><a class="code" href="struct_s_chart_x_y_point.html#2aa25d52c4928b5adf4f1b73896b2c24">00049</a>         <span class="keywordtype">double</span> <a class="code" href="struct_s_chart_x_y_point.html#2aa25d52c4928b5adf4f1b73896b2c24" title="The point X value.">X</a>;
<a name="l00051"></a><a class="code" href="struct_s_chart_x_y_point.html#cde5375a37a5b3b153c2693dbf56fed6">00051</a>         <span class="keywordtype">double</span> <a class="code" href="struct_s_chart_x_y_point.html#cde5375a37a5b3b153c2693dbf56fed6" title="The point Y value.">Y</a>;
<a name="l00052"></a>00052 <span class="preprocessor">        #ifndef NO_USER_DATA</span>
<a name="l00054"></a><a class="code" href="struct_s_chart_x_y_point.html#13f11dcf58dbe5317026ed9d919b3217">00054</a> <span class="preprocessor">        void *pUserData;</span>
<a name="l00055"></a>00055 <span class="preprocessor"></span><span class="preprocessor">        #endif</span>
<a name="l00056"></a>00056 <span class="preprocessor"></span>};
<a name="l00057"></a>00057 
<a name="l00059"></a>00059 
<a name="l00065"></a><a class="code" href="class_c_chart_x_y_serie.html">00065</a> <span class="keyword">class </span><a class="code" href="class_c_chart_x_y_serie.html" title="Specialization of a CChartSerieBase for series having data with an X and an Y value...">CChartXYSerie</a> : <span class="keyword">public</span> <a class="code" href="class_c_chart_serie_base.html" title="Base class for all series of the control.">CChartSerieBase</a>&lt;SChartXYPoint&gt;
<a name="l00066"></a>00066 {
<a name="l00067"></a>00067 <span class="keyword">public</span>:
<a name="l00069"></a>00069         <a class="code" href="class_c_chart_x_y_serie.html#b66d842e4776d2b139af6a27c8313be2" title="Constructor.">CChartXYSerie</a>(<a class="code" href="class_c_chart_ctrl.html" title="The main chart control class.">CChartCtrl</a>* pParent);
<a name="l00071"></a>00071         <span class="keyword">virtual</span> <a class="code" href="class_c_chart_x_y_serie.html#5b598fd291b70d56b97e452935a93614" title="Destructor.">~CChartXYSerie</a>();
<a name="l00072"></a>00072 
<a name="l00074"></a>00074         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_x_y_serie.html#a6b770a879b752a5040a959bd8ea84ed" title="Adds a single data point to the series.">AddPoint</a>(<span class="keywordtype">double</span> X, <span class="keywordtype">double</span> Y);
<a name="l00076"></a>00076 
<a name="l00085"></a>00085         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_x_y_serie.html#19eb7a8120996681108ad8b0061874dc" title="Adds an array of points to the series.">AddPoints</a>(<span class="keywordtype">double</span>* pX, <span class="keywordtype">double</span>* pY, <span class="keywordtype">unsigned</span> Count);
<a name="l00087"></a>00087 
<a name="l00096"></a>00096         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_x_y_serie.html#fb9bb011f36734a765d7f3129184b5cc" title="Sets an array of points to the series.">SetPoints</a>(<span class="keywordtype">double</span>* pX, <span class="keywordtype">double</span>* pY, <span class="keywordtype">unsigned</span> Count);
<a name="l00097"></a>00097 
<a name="l00099"></a>00099         <span class="keywordtype">double</span> <a class="code" href="class_c_chart_x_y_serie.html#9ad7ee92489c7690878768c58d04a313" title="Returns the Y value of a specific point in the series.">GetYPointValue</a>(<span class="keywordtype">unsigned</span> PointIndex) <span class="keyword">const</span>;
<a name="l00101"></a>00101         <span class="keywordtype">double</span> <a class="code" href="class_c_chart_x_y_serie.html#e558cb14b1b9cc2523250902b77e6fd1" title="Returns the X value of a specific point in the series.">GetXPointValue</a>(<span class="keywordtype">unsigned</span> PointIndex) <span class="keyword">const</span>;
<a name="l00103"></a>00103 
<a name="l00110"></a>00110         <span class="keywordtype">void</span>   <a class="code" href="class_c_chart_x_y_serie.html#77215eb9e5c6491c2667540a23bd8ec1" title="Sets the Y value of a specific point in the series.">SetYPointValue</a>(<span class="keywordtype">unsigned</span> PointIndex, <span class="keywordtype">double</span> NewVal);
<a name="l00112"></a>00112 
<a name="l00119"></a>00119         <span class="keywordtype">void</span>   <a class="code" href="class_c_chart_x_y_serie.html#d43ad3e02d53501eb251dddee2749d41" title="Sets the X value of a specific point in the series.">SetXPointValue</a>(<span class="keywordtype">unsigned</span> PointIndex, <span class="keywordtype">double</span> NewVal);      
<a name="l00120"></a>00120         
<a name="l00121"></a>00121 <span class="preprocessor">#ifndef NO_USER_DATA</span>
<a name="l00123"></a>00123 <span class="preprocessor"></span>
<a name="l00128"></a>00128 <span class="preprocessor">        void  SetUserData(unsigned uPointIndex, void* pData);</span>
<a name="l00130"></a>00130 <span class="preprocessor"></span>
<a name="l00135"></a>00135 <span class="preprocessor">        void* GetUserData(unsigned uPointIndex);</span>
<a name="l00136"></a>00136 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00137"></a>00137 <span class="preprocessor"></span>
<a name="l00138"></a>00138 <span class="keyword">protected</span>:
<a name="l00140"></a>00140 
<a name="l00152"></a>00152         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_x_y_serie.html#ca9d20e23a66c9a3ca1242c7ee889acf" title="Retrieves the control points of a bezier curve fitting the points stored in the array...">GetBezierControlPoints</a>(<span class="keywordtype">unsigned</span> uFirst, <span class="keywordtype">unsigned</span> uLast, <a class="code" href="struct_s_chart_x_y_point.html" title="Structure containing a point data with X and Y values.">SChartXYPoint</a>* &amp;pKnots,
<a name="l00153"></a>00153                                 <a class="code" href="struct_s_chart_x_y_point.html" title="Structure containing a point data with X and Y values.">SChartXYPoint</a>* &amp;pFirstControlPoints, <a class="code" href="struct_s_chart_x_y_point.html" title="Structure containing a point data with X and Y values.">SChartXYPoint</a>* &amp;pSecondControlPoints) <span class="keyword">const</span>;
<a name="l00154"></a>00154 
<a name="l00155"></a>00155 <span class="keyword">private</span>:
<a name="l00156"></a>00156         <span class="keywordtype">double</span>* GetFirstControlPoints(<span class="keywordtype">double</span>* rhs, <span class="keywordtype">int</span> Count) <span class="keyword">const</span>;
<a name="l00157"></a>00157 };
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sun Jan 17 13:33:10 2010 for ChartDemo by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer
Belgium Belgium
I am a 29 years old guy and I live with my girlfriend in Hoegaarden, little city from Belgium well known for its white beer Smile | :) .
I studied as an industrial engineer in electronics but I oriented myself more towards software development when I started to work.
Currently I am working in a research centre in mechatronica. I mainly develop in C++ but I also do a bit of Java.
When I have so spare time, I like to read (mainly fantasy) and play electric guitar.

Comments and Discussions