File: group__chartsexample.html

package info (click to toggle)
witty 3.1.2-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 45,512 kB
  • ctags: 35,832
  • sloc: cpp: 69,469; ansic: 66,945; xml: 4,383; sh: 594; perl: 108; makefile: 106
file content (153 lines) | stat: -rw-r--r-- 11,534 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Wt examples: Charts example</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.6 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>Charts example</h1><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Classes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classChartConfig.html">ChartConfig</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A class that allows configuration of a cartesian chart.  <a href="classChartConfig.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTimeSeriesExample.html">TimeSeriesExample</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A widget that demonstrates a times series chart.  <a href="classTimeSeriesExample.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCategoryExample.html">CategoryExample</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A Widget that demonstrates a category chart.  <a href="classCategoryExample.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classScatterPlotExample.html">ScatterPlotExample</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A Widget that demonstrates a scatter plot.  <a href="classScatterPlotExample.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classPieExample.html">PieExample</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A Widget that demonstrates a Pie chart.  <a href="classPieExample.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classChartsExample.html">ChartsExample</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A widget that demonstrates various aspects of the charting lib.  <a href="classChartsExample.html#_details">More...</a><br></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__chartsexample.html#g1ce51cd14c57073cb7839d5e05b59c65">readFromCsv</a> (std::istream &amp;f, <a class="elRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html">Wt::WAbstractItemModel</a> *model, int numRows=-1, bool firstLineIsHeaders=true)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Utility function that reads a model from a CSV file.  <a href="#g1ce51cd14c57073cb7839d5e05b59c65"></a><br></td></tr>
</table>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="g1ce51cd14c57073cb7839d5e05b59c65"></a><!-- doxytag: member="CsvUtil.h::readFromCsv" ref="g1ce51cd14c57073cb7839d5e05b59c65" args="(std::istream &amp;f, Wt::WAbstractItemModel *model, int numRows=-1, bool firstLineIsHeaders=true)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void readFromCsv           </td>
          <td>(</td>
          <td class="paramtype">std::istream &amp;&nbsp;</td>
          <td class="paramname"> <em>f</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="elRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html">Wt::WAbstractItemModel</a> *&nbsp;</td>
          <td class="paramname"> <em>model</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>numRows</em> = <code>-1</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&nbsp;</td>
          <td class="paramname"> <em>firstLineIsHeaders</em> = <code>true</code></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Utility function that reads a model from a CSV file. 
<p>

<p>Definition at line <a class="el" href="treeview-dragdrop_2CsvUtil_8C-source.html#l00009">9</a> of file <a class="el" href="treeview-dragdrop_2CsvUtil_8C-source.html">CsvUtil.C</a>.</p>
<div class="fragment"><pre class="fragment"><a name="l00011"></a>00011 {
<a name="l00012"></a>00012   <span class="keywordtype">int</span> csvRow = 0;
<a name="l00013"></a>00013 
<a name="l00014"></a>00014   <span class="keywordflow">while</span> (f) {
<a name="l00015"></a>00015     std::string line;
<a name="l00016"></a>00016     getline(f, line);
<a name="l00017"></a>00017 
<a name="l00018"></a>00018     <span class="keywordflow">if</span> (f) {
<a name="l00019"></a>00019       <span class="keyword">typedef</span> boost::tokenizer&lt;boost::escaped_list_separator&lt;char&gt; &gt;
<a name="l00020"></a>00020         CsvTokenizer;
<a name="l00021"></a>00021       CsvTokenizer tok(line);
<a name="l00022"></a>00022 
<a name="l00023"></a>00023       <span class="keywordtype">int</span> col = 0;
<a name="l00024"></a>00024       <span class="keywordflow">for</span> (CsvTokenizer::iterator i = tok.begin();
<a name="l00025"></a>00025            i != tok.end(); ++i, ++col) {
<a name="l00026"></a>00026 
<a name="l00027"></a>00027         <span class="keywordflow">if</span> (col &gt;= model-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html#bcf7912a95a0a60f8e9b1c37d30b8383">columnCount</a>())
<a name="l00028"></a>00028           model-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html#1eded9eb68b9247ae2ff371f74a5e5f2">insertColumns</a>(model-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html#bcf7912a95a0a60f8e9b1c37d30b8383">columnCount</a>(),
<a name="l00029"></a>00029                                col + 1 - model-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html#bcf7912a95a0a60f8e9b1c37d30b8383">columnCount</a>());
<a name="l00030"></a>00030 
<a name="l00031"></a>00031         <span class="keywordflow">if</span> (firstLineIsHeaders &amp;&amp; csvRow == 0)
<a name="l00032"></a>00032           model-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html#57f5d417f933440db0d38ece7dd370f4">setHeaderData</a>(col, boost::any(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WString.html#17afc7c43b5b7a710047be4a2c639575">Wt::WString::fromUTF8</a>(*i)));
<a name="l00033"></a>00033         <span class="keywordflow">else</span> {
<a name="l00034"></a>00034           <span class="keywordtype">int</span> dataRow = firstLineIsHeaders ? csvRow - 1 : csvRow;
<a name="l00035"></a>00035 
<a name="l00036"></a>00036           <span class="keywordflow">if</span> (numRows != -1 &amp;&amp; dataRow &gt;= numRows)
<a name="l00037"></a>00037             <span class="keywordflow">return</span>;
<a name="l00038"></a>00038 
<a name="l00039"></a>00039           <span class="keywordflow">if</span> (dataRow &gt;= model-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html#b0709a8f71fd5df882f29bb29fd055f0">rowCount</a>())
<a name="l00040"></a>00040             model-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html#bcafc38dc24fd9edf70eafe834ca411d">insertRows</a>(model-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html#b0709a8f71fd5df882f29bb29fd055f0">rowCount</a>(),
<a name="l00041"></a>00041                               dataRow + 1 - model-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html#b0709a8f71fd5df882f29bb29fd055f0">rowCount</a>());
<a name="l00042"></a>00042 
<a name="l00043"></a>00043           std::string s = *i;
<a name="l00044"></a>00044 
<a name="l00045"></a>00045           boost::any data;
<a name="l00046"></a>00046 
<a name="l00047"></a>00047           <span class="keywordtype">char</span> *end;
<a name="l00048"></a>00048           <span class="keywordtype">int</span> i = std::strtol(s.c_str(), &amp;end, 10);
<a name="l00049"></a>00049           <span class="keywordflow">if</span> (*end == 0)
<a name="l00050"></a>00050             data = boost::any(i);
<a name="l00051"></a>00051           <span class="keywordflow">else</span> {
<a name="l00052"></a>00052             <span class="keywordtype">double</span> d = std::strtod(s.c_str(), &amp;end);
<a name="l00053"></a>00053             <span class="keywordflow">if</span> (*end == 0)
<a name="l00054"></a>00054               data = boost::any(d);
<a name="l00055"></a>00055             <span class="keywordflow">else</span>
<a name="l00056"></a>00056               data = boost::any(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WString.html#17afc7c43b5b7a710047be4a2c639575">Wt::WString::fromUTF8</a>(s));
<a name="l00057"></a>00057           }
<a name="l00058"></a>00058 
<a name="l00059"></a>00059           model-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html#70856db8c322be8c7f397a932165a943">setData</a>(dataRow, col, data);
<a name="l00060"></a>00060         }
<a name="l00061"></a>00061       }
<a name="l00062"></a>00062     }
<a name="l00063"></a>00063 
<a name="l00064"></a>00064     ++csvRow;
<a name="l00065"></a>00065   }
<a name="l00066"></a>00066 }
</pre></div>
<p>

</div>
</div><p>
</div>
<hr size="1"><address style="align: right;"><small>
Generated on Fri Mar 26 17:12:12 2010 for <a href="http://www.webtoolkit.eu/wt/">Wt</a> by&nbsp;<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6</small></address>
</body>
</html>