Click here to Skip to main content
15,884,628 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.2M   100.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/ChartCursor.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/ChartCursor.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"> *      ChartCursor.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">#ifndef _CHARTCURSOR_H_</span>
<a name="l00023"></a>00023 <span class="preprocessor"></span><span class="preprocessor">#define _CHARTCURSOR_H_</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;list&gt;</span>
<a name="l00026"></a>00026 
<a name="l00027"></a>00027 <span class="keyword">class </span><a class="code" href="class_c_chart_ctrl.html" title="The main chart control class.">CChartCtrl</a>;
<a name="l00028"></a>00028 <span class="keyword">class </span><a class="code" href="class_c_chart_cursor.html" title="Base class for cursors which can be added to the chart control.">CChartCursor</a>;
<a name="l00029"></a>00029 
<a name="l00031"></a>00031 
<a name="l00035"></a><a class="code" href="class_c_chart_cursor_listener.html">00035</a> <span class="keyword">class </span><a class="code" href="class_c_chart_cursor_listener.html" title="Interface to implement in order to be notified about a cursor movement.">CChartCursorListener</a>
<a name="l00036"></a>00036 {
<a name="l00037"></a>00037 <span class="keyword">public</span>:
<a name="l00039"></a>00039         <a class="code" href="class_c_chart_cursor_listener.html#249e51c76383c8e727eba793b99455a5" title="Default constructor.">CChartCursorListener</a>();
<a name="l00041"></a>00041         <span class="keyword">virtual</span> <a class="code" href="class_c_chart_cursor_listener.html#a495e18fbabff51261b47a4a79473db6" title="Destructor.">~CChartCursorListener</a>();
<a name="l00042"></a>00042 
<a name="l00044"></a>00044 
<a name="l00054"></a>00054         <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_c_chart_cursor_listener.html#f33ee6368a4a6382523eff1c835ef2e4" title="Pure virtual function to implement in order to be notified about a cursor movement...">OnCursorMoved</a>(<a class="code" href="class_c_chart_cursor.html" title="Base class for cursors which can be added to the chart control.">CChartCursor</a>* pCursor, <span class="keywordtype">double</span> xValue, <span class="keywordtype">double</span> yValue) = 0;
<a name="l00055"></a>00055 };
<a name="l00056"></a>00056 
<a name="l00058"></a>00058 
<a name="l00063"></a><a class="code" href="class_c_chart_cursor.html">00063</a> <span class="keyword">class </span><a class="code" href="class_c_chart_cursor.html" title="Base class for cursors which can be added to the chart control.">CChartCursor</a>
<a name="l00064"></a>00064 {
<a name="l00065"></a>00065         <span class="keyword">friend</span> <a class="code" href="class_c_chart_ctrl.html" title="The main chart control class.">CChartCtrl</a>;
<a name="l00066"></a>00066 
<a name="l00067"></a>00067 <span class="keyword">public</span>:
<a name="l00069"></a>00069         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_cursor.html#bd4387de9a97c4469f78c86e04dd2e69" title="Sets the cursor color.">SetColor</a>(COLORREF cursorColor);
<a name="l00071"></a><a class="code" href="class_c_chart_cursor.html#4b2f24e0bbbfb236c52b94050d2f5a07">00071</a>         <span class="keywordtype">unsigned</span> <a class="code" href="class_c_chart_cursor.html#4b2f24e0bbbfb236c52b94050d2f5a07" title="Retrieves the cursor Id.">GetCursorId</a>()<span class="keyword"> const  </span>{ <span class="keywordflow">return</span> <a class="code" href="class_c_chart_cursor.html#634c001d77168bbe68963644774eac4e" title="The Id of this curosr.">m_uCursorId</a>; }
<a name="l00072"></a>00072 
<a name="l00074"></a>00074         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_cursor.html#93f4600582c8942db0b01eee3c882a3f" title="Registers a cursor listener with this cursor.">RegisterListener</a>(<a class="code" href="class_c_chart_cursor_listener.html" title="Interface to implement in order to be notified about a cursor movement.">CChartCursorListener</a>* pListener);
<a name="l00075"></a>00075 
<a name="l00076"></a>00076 <span class="keyword">protected</span>:
<a name="l00078"></a>00078         <a class="code" href="class_c_chart_cursor.html#255fd9c02744eab27d12551a218c19d8" title="Default constructor.">CChartCursor</a>(<a class="code" href="class_c_chart_ctrl.html" title="The main chart control class.">CChartCtrl</a>* pParent); 
<a name="l00080"></a>00080         <span class="keyword">virtual</span> <a class="code" href="class_c_chart_cursor.html#ed9723360dfa27567b8dfb34f4bd6ca9" title="Default destructor.">~CChartCursor</a>();
<a name="l00081"></a>00081 
<a name="l00083"></a>00083 
<a name="l00087"></a>00087         <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_c_chart_cursor.html#fe447ebc13060419ef7b60410ba5532b" title="Pure virtual function that is called when the mouse moved on the plot area.">OnMouseMove</a>(CPoint mousePoint) = 0;
<a name="l00089"></a>00089 
<a name="l00093"></a><a class="code" href="class_c_chart_cursor.html#bd95379b8f28b93191de1bf5e02a0126">00093</a>         <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_c_chart_cursor.html#bd95379b8f28b93191de1bf5e02a0126" title="Virtual function that is called when the left mouse button is pressed.">OnMouseButtonDown</a>(CPoint <span class="comment">/*mousePoint*/</span>)  { }
<a name="l00095"></a>00095 
<a name="l00099"></a><a class="code" href="class_c_chart_cursor.html#93394fc366bf6f76aa0f4cea0858a8f1">00099</a>         <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_c_chart_cursor.html#93394fc366bf6f76aa0f4cea0858a8f1" title="Virtual function that is called when the left mouse button is released.">OnMouseButtonUp</a>(CPoint <span class="comment">/*mousePoint*/</span>)    { }
<a name="l00100"></a>00100 
<a name="l00102"></a>00102         <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_c_chart_cursor.html#122c0784ebeec719cf040692fe218f09" title="Pure virtual function that draws the cursor.">Draw</a>(CDC* pDC) = 0;
<a name="l00104"></a>00104 
<a name="l00107"></a>00107         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_cursor.html#99684299e615294469bfb4f0c6079dc8" title="Function that is called by the child classes when the cursor has been moved.">CursorMoved</a>(<span class="keywordtype">double</span> newXValue, <span class="keywordtype">double</span> newYValue);
<a name="l00108"></a>00108 
<a name="l00109"></a>00109 
<a name="l00111"></a><a class="code" href="class_c_chart_cursor.html#82f0fae88de7676e725cb394c7350bbe">00111</a>         COLORREF <a class="code" href="class_c_chart_cursor.html#82f0fae88de7676e725cb394c7350bbe" title="The color of the cursor.">m_colCursor</a>;
<a name="l00113"></a><a class="code" href="class_c_chart_cursor.html#c913e38511292baeb5b8f1ae26e32444">00113</a>         <a class="code" href="class_c_chart_ctrl.html" title="The main chart control class.">CChartCtrl</a>* <a class="code" href="class_c_chart_cursor.html#c913e38511292baeb5b8f1ae26e32444" title="The parent charting control.">m_pParentCtrl</a>;
<a name="l00114"></a>00114 
<a name="l00116"></a><a class="code" href="class_c_chart_cursor.html#a60c63b9ba30caae2c4d4971a2d617af">00116</a>         <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <a class="code" href="class_c_chart_cursor.html#a60c63b9ba30caae2c4d4971a2d617af" title="Static variable holding the next free cursor Id.">m_uNextFreeId</a>;
<a name="l00118"></a><a class="code" href="class_c_chart_cursor.html#634c001d77168bbe68963644774eac4e">00118</a>         <span class="keywordtype">unsigned</span> <a class="code" href="class_c_chart_cursor.html#634c001d77168bbe68963644774eac4e" title="The Id of this curosr.">m_uCursorId</a>;
<a name="l00119"></a>00119 
<a name="l00120"></a>00120         <span class="keyword">typedef</span> std::list&lt;CChartCursorListener*&gt; TListenerList;
<a name="l00122"></a><a class="code" href="class_c_chart_cursor.html#fbe312c829d2bbcdd73ce92211e1614c">00122</a>         TListenerList <a class="code" href="class_c_chart_cursor.html#fbe312c829d2bbcdd73ce92211e1614c" title="List of all listeners registered with this cursor.">m_lstListeners</a>;
<a name="l00123"></a>00123 };
<a name="l00124"></a>00124 
<a name="l00125"></a>00125 <span class="preprocessor">#endif  // _CHARTCURSOR_H_</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sun Jan 17 13:33:09 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