Click here to Skip to main content
15,892,059 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/ChartGanttSerie.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/ChartGanttSerie.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"> *      ChartGanttSerie.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_gantt_point.html">00026</a> <span class="keyword">struct </span><a class="code" href="struct_s_chart_gantt_point.html" title="Point structure used as template parameter for gantt series.">SChartGanttPoint</a>
<a name="l00027"></a>00027 {
<a name="l00029"></a><a class="code" href="struct_s_chart_gantt_point.html#4679225acdd9977911b77b685783f300">00029</a>         <a class="code" href="struct_s_chart_gantt_point.html#4679225acdd9977911b77b685783f300" title="Default constructor.">SChartGanttPoint</a>() : <a class="code" href="struct_s_chart_gantt_point.html#8039e290a13ea1391fc33b90a7aa8542" title="The start time of the gantt point.">StartTime</a>(0.0), <a class="code" href="struct_s_chart_gantt_point.html#9c578dbcbdc93032122dd23caa044fe9" title="The end time of the gantt point.">EndTime</a>(0.0), <a class="code" href="struct_s_chart_gantt_point.html#b1b8a17aaf677b687c08fae0e5a7b2a3" title="The Y value of the gantt point.">YValue</a>(0.0)  { }
<a name="l00031"></a><a class="code" href="struct_s_chart_gantt_point.html#a98ec78d5aff8740b03a3e4eb838a8a2">00031</a>         <a class="code" href="struct_s_chart_gantt_point.html#4679225acdd9977911b77b685783f300" title="Default constructor.">SChartGanttPoint</a>(<span class="keywordtype">double</span> Start, <span class="keywordtype">double</span> End, <span class="keywordtype">double</span> YVal) 
<a name="l00032"></a>00032                 : <a class="code" href="struct_s_chart_gantt_point.html#8039e290a13ea1391fc33b90a7aa8542" title="The start time of the gantt point.">StartTime</a>(Start), <a class="code" href="struct_s_chart_gantt_point.html#9c578dbcbdc93032122dd23caa044fe9" title="The end time of the gantt point.">EndTime</a>(End), <a class="code" href="struct_s_chart_gantt_point.html#b1b8a17aaf677b687c08fae0e5a7b2a3" title="The Y value of the gantt point.">YValue</a>(YVal)  { }
<a name="l00033"></a>00033 
<a name="l00035"></a><a class="code" href="struct_s_chart_gantt_point.html#8039e290a13ea1391fc33b90a7aa8542">00035</a>         <span class="keywordtype">double</span> <a class="code" href="struct_s_chart_gantt_point.html#8039e290a13ea1391fc33b90a7aa8542" title="The start time of the gantt point.">StartTime</a>;
<a name="l00037"></a><a class="code" href="struct_s_chart_gantt_point.html#9c578dbcbdc93032122dd23caa044fe9">00037</a>         <span class="keywordtype">double</span> <a class="code" href="struct_s_chart_gantt_point.html#9c578dbcbdc93032122dd23caa044fe9" title="The end time of the gantt point.">EndTime</a>;
<a name="l00039"></a><a class="code" href="struct_s_chart_gantt_point.html#b1b8a17aaf677b687c08fae0e5a7b2a3">00039</a>         <span class="keywordtype">double</span> <a class="code" href="struct_s_chart_gantt_point.html#b1b8a17aaf677b687c08fae0e5a7b2a3" title="The Y value of the gantt point.">YValue</a>;
<a name="l00040"></a>00040 
<a name="l00042"></a><a class="code" href="struct_s_chart_gantt_point.html#8d18df542330f8248a40c41ff271b756">00042</a>         <span class="keywordtype">double</span> <a class="code" href="struct_s_chart_gantt_point.html#8d18df542330f8248a40c41ff271b756" title="Returns the X value of the point, which is the average between start time and end...">GetX</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> (<a class="code" href="struct_s_chart_gantt_point.html#9c578dbcbdc93032122dd23caa044fe9" title="The end time of the gantt point.">EndTime</a>-<a class="code" href="struct_s_chart_gantt_point.html#8039e290a13ea1391fc33b90a7aa8542" title="The start time of the gantt point.">StartTime</a>)/2; }
<a name="l00044"></a><a class="code" href="struct_s_chart_gantt_point.html#b21b1b2cfb22e7c1292f873d3177d8eb">00044</a>         <span class="keywordtype">double</span> <a class="code" href="struct_s_chart_gantt_point.html#b21b1b2cfb22e7c1292f873d3177d8eb" title="Returns the Y value.">GetY</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="struct_s_chart_gantt_point.html#b1b8a17aaf677b687c08fae0e5a7b2a3" title="The Y value of the gantt point.">YValue</a>; }
<a name="l00046"></a><a class="code" href="struct_s_chart_gantt_point.html#bd783b90d088b058263138be75b58faa">00046</a>         <span class="keywordtype">double</span> <a class="code" href="struct_s_chart_gantt_point.html#bd783b90d088b058263138be75b58faa" title="Returns the start time.">GetXMin</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="struct_s_chart_gantt_point.html#8039e290a13ea1391fc33b90a7aa8542" title="The start time of the gantt point.">StartTime</a>; }
<a name="l00048"></a><a class="code" href="struct_s_chart_gantt_point.html#d963c737eafe287bf55e89ad772e03cb">00048</a>         <span class="keywordtype">double</span> <a class="code" href="struct_s_chart_gantt_point.html#d963c737eafe287bf55e89ad772e03cb" title="Returns the end time.">GetXMax</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="struct_s_chart_gantt_point.html#9c578dbcbdc93032122dd23caa044fe9" title="The end time of the gantt point.">EndTime</a>; }
<a name="l00050"></a><a class="code" href="struct_s_chart_gantt_point.html#699c1c61d94d768140d478537999fd21">00050</a>         <span class="keywordtype">double</span> <a class="code" href="struct_s_chart_gantt_point.html#699c1c61d94d768140d478537999fd21" title="Returns the Y value.">GetYMin</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="struct_s_chart_gantt_point.html#b1b8a17aaf677b687c08fae0e5a7b2a3" title="The Y value of the gantt point.">YValue</a>; }
<a name="l00052"></a><a class="code" href="struct_s_chart_gantt_point.html#acb13ec0d7260c1d34eddf9218880c7e">00052</a>         <span class="keywordtype">double</span> <a class="code" href="struct_s_chart_gantt_point.html#acb13ec0d7260c1d34eddf9218880c7e" title="Returns the Y value.">GetYMax</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="struct_s_chart_gantt_point.html#b1b8a17aaf677b687c08fae0e5a7b2a3" title="The Y value of the gantt point.">YValue</a>; }
<a name="l00053"></a>00053 };
<a name="l00054"></a>00054 
<a name="l00056"></a>00056 
<a name="l00063"></a><a class="code" href="class_c_chart_gantt_serie.html">00063</a> <span class="keyword">class </span><a class="code" href="class_c_chart_gantt_serie.html" title="Specialization of a CChartSerieBase to display a gantt series.">CChartGanttSerie</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;SChartGanttPoint&gt;
<a name="l00064"></a>00064 {
<a name="l00065"></a>00065 <span class="keyword">public</span>:
<a name="l00067"></a>00067         <a class="code" href="class_c_chart_gantt_serie.html#a56c6915075088cd0d721fac9c5f72a6" title="Constructor.">CChartGanttSerie</a>(<a class="code" href="class_c_chart_ctrl.html" title="The main chart control class.">CChartCtrl</a>* pParent);
<a name="l00069"></a>00069         <a class="code" href="class_c_chart_gantt_serie.html#f3c6a96334d352dc23c966dcc2fbb67c" title="Destructor.">~CChartGanttSerie</a>();
<a name="l00070"></a>00070 
<a name="l00072"></a>00072 
<a name="l00080"></a>00080         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_gantt_serie.html#80bce81a3c72fc388ae24d155f676c02" title="Adds a new point to the series.">AddPoint</a>(<span class="keywordtype">double</span> StartTime, <span class="keywordtype">double</span> EndTime, <span class="keywordtype">double</span> YValue);
<a name="l00081"></a>00081 
<a name="l00083"></a>00083 
<a name="l00090"></a>00090         <span class="keywordtype">bool</span> <a class="code" href="class_c_chart_gantt_serie.html#233df9834c1c65a6e551101a665addfd" title="Tests if a certain screen point is on the series.">IsPointOnSerie</a>(<span class="keyword">const</span> CPoint&amp; screenPoint, <span class="keywordtype">unsigned</span>&amp; uIndex) <span class="keyword">const</span>;
<a name="l00091"></a>00091 
<a name="l00093"></a>00093         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_gantt_serie.html#9c6c1dff4283bc23226904ee1398bde6" title="Sets the bars border color.">SetBorderColor</a>(COLORREF BorderColor);
<a name="l00095"></a><a class="code" href="class_c_chart_gantt_serie.html#300dd70e722de80b33d427280b0a5758">00095</a>         COLORREF <a class="code" href="class_c_chart_gantt_serie.html#300dd70e722de80b33d427280b0a5758" title="Returns the bars border color.">GetBorderColor</a>()<span class="keyword"> const                    </span>{ <span class="keywordflow">return</span> m_BorderColor; }
<a name="l00097"></a>00097         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_gantt_serie.html#aaa2e466f8f53da1c84820ff544efcb0" title="Sets the bars border width.">SetBorderWidth</a>(<span class="keywordtype">int</span> Width);
<a name="l00099"></a><a class="code" href="class_c_chart_gantt_serie.html#70426eb540303a29cef660873ea66c1b">00099</a>         <span class="keywordtype">int</span>  <a class="code" href="class_c_chart_gantt_serie.html#70426eb540303a29cef660873ea66c1b" title="Returns the bars border width.">GetBorderWidth</a>()<span class="keyword"> const             </span>{ <span class="keywordflow">return</span> m_iBorderWidth;  }
<a name="l00101"></a>00101         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_gantt_serie.html#353a591f9b66988d44ab96211d41f75a" title="Sets the bars width (in pixels).">SetBarWidth</a>(<span class="keywordtype">int</span> Width);
<a name="l00103"></a><a class="code" href="class_c_chart_gantt_serie.html#1e81a6bc92360c62cde924e6fd5c4b31">00103</a>         <span class="keywordtype">int</span>  <a class="code" href="class_c_chart_gantt_serie.html#1e81a6bc92360c62cde924e6fd5c4b31" title="Returns the bars width (in pixels).">GetBarWidth</a>()<span class="keyword"> const                </span>{ <span class="keywordflow">return</span> m_iBarWidth;  }
<a name="l00104"></a>00104 
<a name="l00106"></a>00106         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_gantt_serie.html#a227b87ef2ae585adb48f6b306274526" title="Specifies if a gradient is applied to the bars.">ShowGradient</a>(<span class="keywordtype">bool</span> bShow);
<a name="l00108"></a>00108 
<a name="l00115"></a>00115         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_gantt_serie.html#1fd1a7ffcdd1fb80d78a9243f8a47ca3" title="Sets the gradient style.">SetGradient</a>(COLORREF GradientColor, EGradientType GradientType);
<a name="l00116"></a>00116 
<a name="l00117"></a>00117 <span class="keyword">protected</span>:
<a name="l00119"></a>00119 
<a name="l00125"></a>00125     <span class="keywordtype">void</span> <a class="code" href="class_c_chart_gantt_serie.html#9dd98507133d52742ac012399b6335a7" title="Draws the legend icon for the series.">DrawLegend</a>(CDC* pDC, <span class="keyword">const</span> CRect&amp; rectBitmap) <span class="keyword">const</span>;
<a name="l00126"></a>00126 
<a name="l00128"></a>00128 
<a name="l00134"></a>00134         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_gantt_serie.html#f82a8643c50f10c7893c1e83f1d9c43f" title="Draws the most recent points of the series.">Draw</a>(CDC* pDC);
<a name="l00136"></a>00136 
<a name="l00140"></a>00140         <span class="keywordtype">void</span> <a class="code" href="class_c_chart_gantt_serie.html#888aa7dab2231e3af81bed326ead772f" title="Redraws the full series.">DrawAll</a>(CDC *pDC);
<a name="l00141"></a>00141 
<a name="l00142"></a>00142 <span class="keyword">private</span>:
<a name="l00144"></a>00144         CRect GetBarRectangle(<span class="keywordtype">unsigned</span> uPointIndex) <span class="keyword">const</span>;
<a name="l00145"></a>00145 
<a name="l00146"></a>00146         <span class="keywordtype">void</span> DrawBar(CDC* pDC, CBrush* pFillBrush, CBrush* pBorderBrush, 
<a name="l00147"></a>00147                                  CRect BarRect);
<a name="l00148"></a>00148 
<a name="l00150"></a>00150         <span class="keywordtype">int</span> m_iBarWidth;
<a name="l00152"></a>00152         <span class="keywordtype">int</span> m_iBorderWidth;
<a name="l00154"></a>00154         COLORREF m_BorderColor;
<a name="l00155"></a>00155 
<a name="l00157"></a>00157         <span class="keywordtype">bool</span> m_bGradient;
<a name="l00159"></a>00159         COLORREF m_GradientColor;
<a name="l00161"></a>00161         EGradientType m_GradientType;
<a name="l00162"></a>00162 };
</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