1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3
<title>Qwt User's Guide: qwt_plot_curve.cpp Source File</title>
4
<link href="doxygen.css" rel="stylesheet" type="text/css">
5
<link href="tabs.css" rel="stylesheet" type="text/css">
7
<!-- Generated by Doxygen 1.4.6 -->
10
<li><a href="index.html"><span>Main Page</span></a></li>
11
<li><a href="classes.html"><span>Classes</span></a></li>
12
<li id="current"><a href="files.html"><span>Files</span></a></li>
13
<li><a href="pages.html"><span>Related Pages</span></a></li>
15
<h1>qwt_plot_curve.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************</span>
16
<a name="l00002"></a>00002 <span class="comment"> * Qwt Widget Library</span>
17
<a name="l00003"></a>00003 <span class="comment"> * Copyright (C) 1997 Josef Wilgen</span>
18
<a name="l00004"></a>00004 <span class="comment"> * Copyright (C) 2002 Uwe Rathmann</span>
19
<a name="l00005"></a>00005 <span class="comment"> *</span>
20
<a name="l00006"></a>00006 <span class="comment"> * This library is free software; you can redistribute it and/or</span>
21
<a name="l00007"></a>00007 <span class="comment"> * modify it under the terms of the Qwt License, Version 1.0</span>
22
<a name="l00008"></a>00008 <span class="comment"> *****************************************************************************/</span>
23
<a name="l00009"></a>00009
24
<a name="l00010"></a>00010 <span class="preprocessor">#include <qpainter.h></span>
25
<a name="l00011"></a>00011 <span class="preprocessor">#include <qpixmap.h></span>
26
<a name="l00012"></a>00012 <span class="preprocessor">#include <qbitarray.h></span>
27
<a name="l00013"></a>00013 <span class="preprocessor">#include "qwt_global.h"</span>
28
<a name="l00014"></a>00014 <span class="preprocessor">#include "qwt_legend.h"</span>
29
<a name="l00015"></a>00015 <span class="preprocessor">#include "qwt_legend_item.h"</span>
30
<a name="l00016"></a>00016 <span class="preprocessor">#include "qwt_data.h"</span>
31
<a name="l00017"></a>00017 <span class="preprocessor">#include "qwt_rect.h"</span>
32
<a name="l00018"></a>00018 <span class="preprocessor">#include "qwt_scale_map.h"</span>
33
<a name="l00019"></a>00019 <span class="preprocessor">#include "qwt_double_rect.h"</span>
34
<a name="l00020"></a>00020 <span class="preprocessor">#include "qwt_math.h"</span>
35
<a name="l00021"></a>00021 <span class="preprocessor">#include "qwt_painter.h"</span>
36
<a name="l00022"></a>00022 <span class="preprocessor">#include "qwt_plot.h"</span>
37
<a name="l00023"></a>00023 <span class="preprocessor">#include "qwt_plot_canvas.h"</span>
38
<a name="l00024"></a>00024 <span class="preprocessor">#include "qwt_curve_fitter.h"</span>
39
<a name="l00025"></a>00025 <span class="preprocessor">#include "qwt_symbol.h"</span>
40
<a name="l00026"></a>00026 <span class="preprocessor">#include "qwt_plot_curve.h"</span>
41
<a name="l00027"></a>00027
42
<a name="l00028"></a>00028 <span class="preprocessor">#if QT_VERSION >= 0x040000</span>
43
<a name="l00029"></a>00029 <span class="preprocessor"></span>
44
<a name="l00030"></a>00030 <span class="preprocessor">#include <qevent.h></span>
45
<a name="l00031"></a>00031
46
<a name="l00032"></a>00032 <span class="keyword">class </span>QwtPlotCurvePaintHelper: <span class="keyword">public</span> QObject
47
<a name="l00033"></a>00033 {
48
<a name="l00034"></a>00034 <span class="keyword">public</span>:
49
<a name="l00035"></a>00035 QwtPlotCurvePaintHelper(<span class="keyword">const</span> <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *curve, <span class="keywordtype">int</span> from, <span class="keywordtype">int</span> to):
50
<a name="l00036"></a>00036 _curve(curve),
51
<a name="l00037"></a>00037 _from(from),
52
<a name="l00038"></a>00038 _to(to)
53
<a name="l00039"></a>00039 {
54
<a name="l00040"></a>00040 }
55
<a name="l00041"></a>00041
56
<a name="l00042"></a>00042 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> eventFilter(QObject *, QEvent *event)
57
<a name="l00043"></a>00043 {
58
<a name="l00044"></a>00044 <span class="keywordflow">if</span> ( event->type() == QEvent::Paint )
59
<a name="l00045"></a>00045 {
60
<a name="l00046"></a>00046 _curve->draw(_from, _to);
61
<a name="l00047"></a>00047 <span class="keywordflow">return</span> <span class="keyword">true</span>;
62
<a name="l00048"></a>00048 }
63
<a name="l00049"></a>00049 <span class="keywordflow">return</span> <span class="keyword">false</span>;
64
<a name="l00050"></a>00050 }
65
<a name="l00051"></a>00051 <span class="keyword">private</span>:
66
<a name="l00052"></a>00052 <span class="keyword">const</span> <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *_curve;
67
<a name="l00053"></a>00053 <span class="keywordtype">int</span> _from;
68
<a name="l00054"></a>00054 <span class="keywordtype">int</span> _to;
69
<a name="l00055"></a>00055 };
70
<a name="l00056"></a>00056
71
<a name="l00057"></a>00057 <span class="preprocessor">#endif // QT_VERSION >= 0x040000</span>
72
<a name="l00058"></a>00058 <span class="preprocessor"></span>
73
<a name="l00059"></a>00059 <span class="keyword">static</span> <span class="keywordtype">int</span> verifyRange(<span class="keywordtype">int</span> size, <span class="keywordtype">int</span> &i1, <span class="keywordtype">int</span> &i2)
74
<a name="l00060"></a>00060 {
75
<a name="l00061"></a>00061 <span class="keywordflow">if</span> (size < 1)
76
<a name="l00062"></a>00062 <span class="keywordflow">return</span> 0;
77
<a name="l00063"></a>00063
78
<a name="l00064"></a>00064 i1 = qwtLim(i1, 0, size-1);
79
<a name="l00065"></a>00065 i2 = qwtLim(i2, 0, size-1);
80
<a name="l00066"></a>00066
81
<a name="l00067"></a>00067 <span class="keywordflow">if</span> ( i1 > i2 )
82
<a name="l00068"></a>00068 qSwap(i1, i2);
83
<a name="l00069"></a>00069
84
<a name="l00070"></a>00070 <span class="keywordflow">return</span> (i2 - i1 + 1);
85
<a name="l00071"></a>00071 }
86
<a name="l00072"></a>00072
87
<a name="l00073"></a>00073 <span class="keyword">class </span>QwtPlotCurve::PrivateData
88
<a name="l00074"></a>00074 {
89
<a name="l00075"></a>00075 <span class="keyword">public</span>:
90
<a name="l00076"></a>00076 <span class="keyword">class </span>PixelMatrix: <span class="keyword">private</span> QBitArray
91
<a name="l00077"></a>00077 {
92
<a name="l00078"></a>00078 <span class="keyword">public</span>:
93
<a name="l00079"></a>00079 PixelMatrix(<span class="keyword">const</span> QRect& rect):
94
<a name="l00080"></a>00080 QBitArray(rect.width() * rect.height()),
95
<a name="l00081"></a>00081 _rect(rect)
96
<a name="l00082"></a>00082 {
97
<a name="l00083"></a>00083 fill(<span class="keyword">false</span>);
98
<a name="l00084"></a>00084 }
99
<a name="l00085"></a>00085
100
<a name="l00086"></a>00086 <span class="keyword">inline</span> <span class="keywordtype">bool</span> testPixel(<span class="keyword">const</span> QPoint& pos)
101
<a name="l00087"></a>00087 {
102
<a name="l00088"></a>00088 <span class="keywordflow">if</span> ( !_rect.contains(pos) )
103
<a name="l00089"></a>00089 <span class="keywordflow">return</span> <span class="keyword">false</span>;
104
<a name="l00090"></a>00090
105
<a name="l00091"></a>00091 <span class="keyword">const</span> <span class="keywordtype">int</span> idx = _rect.width() * (pos.y() - _rect.y()) +
106
<a name="l00092"></a>00092 (pos.x() - _rect.x());
107
<a name="l00093"></a>00093
108
<a name="l00094"></a>00094 <span class="keyword">const</span> <span class="keywordtype">bool</span> marked = testBit(idx);
109
<a name="l00095"></a>00095 <span class="keywordflow">if</span> ( !marked )
110
<a name="l00096"></a>00096 setBit(idx, <span class="keyword">true</span>);
111
<a name="l00097"></a>00097
112
<a name="l00098"></a>00098 <span class="keywordflow">return</span> !marked;
113
<a name="l00099"></a>00099 }
114
<a name="l00100"></a>00100
115
<a name="l00101"></a>00101 <span class="keyword">private</span>:
116
<a name="l00102"></a>00102 QRect _rect;
117
<a name="l00103"></a>00103 };
118
<a name="l00104"></a>00104
119
<a name="l00105"></a>00105 PrivateData():
120
<a name="l00106"></a>00106 <a class="code" href="class_qwt_plot_curve.html#203a29e61eda8434826a12f14db96255">curveType</a>(Yfx),
121
<a name="l00107"></a>00107 <a class="code" href="class_qwt_plot_curve.html#2df43bdea2a17118c9114d6fa774e598">style</a>(<a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a>::Lines),
122
<a name="l00108"></a>00108 reference(0.0),
123
<a name="l00109"></a>00109 attributes(0),
124
<a name="l00110"></a>00110 paintAttributes(0)
125
<a name="l00111"></a>00111 {
126
<a name="l00112"></a>00112 <a class="code" href="class_qwt_plot_curve.html#778aafd1385ce833821751d0a8635cef">pen</a> = QPen(Qt::black, 0);
127
<a name="l00113"></a>00113 <a class="code" href="class_qwt_plot_curve.html#af299522e4ad972996c781aacc940d31">curveFitter</a> = <span class="keyword">new</span> <a class="code" href="class_qwt_spline_curve_fitter.html">QwtSplineCurveFitter</a>;
128
<a name="l00114"></a>00114 }
129
<a name="l00115"></a>00115
130
<a name="l00116"></a>00116 ~PrivateData()
131
<a name="l00117"></a>00117 {
132
<a name="l00118"></a>00118 <span class="keyword">delete</span> <a class="code" href="class_qwt_plot_curve.html#af299522e4ad972996c781aacc940d31">curveFitter</a>;
133
<a name="l00119"></a>00119 }
134
<a name="l00120"></a>00120
135
<a name="l00121"></a>00121 <a class="code" href="class_qwt_plot_curve.html#c173d5059500d1c783602e33689714f5">QwtPlotCurve::CurveType</a> <a class="code" href="class_qwt_plot_curve.html#203a29e61eda8434826a12f14db96255">curveType</a>;
136
<a name="l00122"></a>00122 <a class="code" href="class_qwt_plot_curve.html#15998aa80a11ba6ba80eebabaf773f70">QwtPlotCurve::CurveStyle</a> <a class="code" href="class_qwt_plot_curve.html#2df43bdea2a17118c9114d6fa774e598">style</a>;
137
<a name="l00123"></a>00123 <span class="keywordtype">double</span> reference;
138
<a name="l00124"></a>00124
139
<a name="l00125"></a>00125 <a class="code" href="class_qwt_symbol.html">QwtSymbol</a> sym;
140
<a name="l00126"></a>00126 <a class="code" href="class_qwt_curve_fitter.html">QwtCurveFitter</a> *<a class="code" href="class_qwt_plot_curve.html#af299522e4ad972996c781aacc940d31">curveFitter</a>;
141
<a name="l00127"></a>00127
142
<a name="l00128"></a>00128 QPen <a class="code" href="class_qwt_plot_curve.html#778aafd1385ce833821751d0a8635cef">pen</a>;
143
<a name="l00129"></a>00129 QBrush <a class="code" href="class_qwt_plot_curve.html#72b678ebb8e4821c1f85351292ce5697">brush</a>;
144
<a name="l00130"></a>00130
145
<a name="l00131"></a>00131 <span class="keywordtype">int</span> attributes;
146
<a name="l00132"></a>00132 <span class="keywordtype">int</span> paintAttributes;
147
<a name="l00133"></a>00133 };
148
<a name="l00134"></a>00134
149
<a name="l00138"></a><a class="code" href="class_qwt_plot_curve.html#798339b953deb10e3dddb0f8b56427c0">00138</a> <a class="code" href="class_qwt_plot_curve.html#798339b953deb10e3dddb0f8b56427c0">QwtPlotCurve::QwtPlotCurve</a>():
150
<a name="l00139"></a>00139 <a class="code" href="class_qwt_plot_item.html">QwtPlotItem</a>(<a class="code" href="class_qwt_text.html">QwtText</a>())
151
<a name="l00140"></a>00140 {
152
<a name="l00141"></a>00141 <a class="code" href="class_qwt_plot_curve.html#7afecd61327d56ddc76687d119e92b5d">init</a>();
153
<a name="l00142"></a>00142 }
154
<a name="l00143"></a>00143
155
<a name="l00148"></a><a class="code" href="class_qwt_plot_curve.html#3bcaa88363509f4bc1ad92bee498f203">00148</a> <a class="code" href="class_qwt_plot_curve.html#798339b953deb10e3dddb0f8b56427c0">QwtPlotCurve::QwtPlotCurve</a>(<span class="keyword">const</span> <a class="code" href="class_qwt_text.html">QwtText</a> &title):
156
<a name="l00149"></a>00149 <a class="code" href="class_qwt_plot_item.html">QwtPlotItem</a>(title)
157
<a name="l00150"></a>00150 {
158
<a name="l00151"></a>00151 <a class="code" href="class_qwt_plot_curve.html#7afecd61327d56ddc76687d119e92b5d">init</a>();
159
<a name="l00152"></a>00152 }
160
<a name="l00153"></a>00153
161
<a name="l00158"></a><a class="code" href="class_qwt_plot_curve.html#0abb61c8a31fad952bfe45a1f325209f">00158</a> <a class="code" href="class_qwt_plot_curve.html#798339b953deb10e3dddb0f8b56427c0">QwtPlotCurve::QwtPlotCurve</a>(<span class="keyword">const</span> QString &title):
162
<a name="l00159"></a>00159 <a class="code" href="class_qwt_plot_item.html">QwtPlotItem</a>(<a class="code" href="class_qwt_text.html">QwtText</a>(title))
163
<a name="l00160"></a>00160 {
164
<a name="l00161"></a>00161 <a class="code" href="class_qwt_plot_curve.html#7afecd61327d56ddc76687d119e92b5d">init</a>();
165
<a name="l00162"></a>00162 }
166
<a name="l00163"></a>00163
167
<a name="l00165"></a><a class="code" href="class_qwt_plot_curve.html#a05ec6d3883821a8e62330fbeeb85dbd">00165</a> <a class="code" href="class_qwt_plot_curve.html#a05ec6d3883821a8e62330fbeeb85dbd">QwtPlotCurve::~QwtPlotCurve</a>()
168
<a name="l00166"></a>00166 {
169
<a name="l00167"></a>00167 <span class="keyword">delete</span> d_xy;
170
<a name="l00168"></a>00168 <span class="keyword">delete</span> d_data;
171
<a name="l00169"></a>00169 }
172
<a name="l00170"></a>00170
173
<a name="l00174"></a><a class="code" href="class_qwt_plot_curve.html#7afecd61327d56ddc76687d119e92b5d">00174</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#7afecd61327d56ddc76687d119e92b5d">QwtPlotCurve::init</a>()
174
<a name="l00175"></a>00175 {
175
<a name="l00176"></a>00176 <a class="code" href="class_qwt_plot_item.html#5a335be8ff488809a2cf7f4b734ad1b6">setItemAttribute</a>(QwtPlotItem::Legend);
176
<a name="l00177"></a>00177 <a class="code" href="class_qwt_plot_item.html#5a335be8ff488809a2cf7f4b734ad1b6">setItemAttribute</a>(QwtPlotItem::AutoScale);
177
<a name="l00178"></a>00178
178
<a name="l00179"></a>00179 d_data = <span class="keyword">new</span> PrivateData;
179
<a name="l00180"></a>00180 d_xy = <span class="keyword">new</span> <a class="code" href="class_qwt_polygon_f_data.html">QwtPolygonFData</a>(QwtArray<QwtDoublePoint>());
180
<a name="l00181"></a>00181
181
<a name="l00182"></a>00182 <a class="code" href="class_qwt_plot_item.html#57d90e4146133b59d589c71b3a643e82">setZ</a>(20.0);
182
<a name="l00183"></a>00183 }
183
<a name="l00184"></a>00184
184
<a name="l00185"></a><a class="code" href="class_qwt_plot_curve.html#1cb75062e781f4e0839a6cd2081c3928">00185</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot_curve.html#1cb75062e781f4e0839a6cd2081c3928">QwtPlotCurve::rtti</a>()<span class="keyword"> const</span>
185
<a name="l00186"></a>00186 <span class="keyword"></span>{
186
<a name="l00187"></a>00187 <span class="keywordflow">return</span> QwtPlotItem::Rtti_PlotCurve;
187
<a name="l00188"></a>00188 }
188
<a name="l00189"></a>00189
189
<a name="l00211"></a><a class="code" href="class_qwt_plot_curve.html#7f9c70366415b5cb068af80be5bf3748">00211</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#7f9c70366415b5cb068af80be5bf3748">QwtPlotCurve::setPaintAttribute</a>(<a class="code" href="class_qwt_plot_curve.html#96db1b854c63bfbc452c943251a11b66">PaintAttribute</a> attribute, <span class="keywordtype">bool</span> on)
190
<a name="l00212"></a>00212 {
191
<a name="l00213"></a>00213 <span class="keywordflow">if</span> ( on )
192
<a name="l00214"></a>00214 d_data->paintAttributes |= attribute;
193
<a name="l00215"></a>00215 <span class="keywordflow">else</span>
194
<a name="l00216"></a>00216 d_data->paintAttributes &= ~attribute;
195
<a name="l00217"></a>00217 }
196
<a name="l00218"></a>00218
197
<a name="l00223"></a><a class="code" href="class_qwt_plot_curve.html#d262cf6b8448d3cb693cbceecc6d8481">00223</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot_curve.html#d262cf6b8448d3cb693cbceecc6d8481">QwtPlotCurve::testPaintAttribute</a>(<a class="code" href="class_qwt_plot_curve.html#96db1b854c63bfbc452c943251a11b66">PaintAttribute</a> attribute)<span class="keyword"> const</span>
198
<a name="l00224"></a>00224 <span class="keyword"></span>{
199
<a name="l00225"></a>00225 <span class="keywordflow">return</span> (d_data->paintAttributes & attribute);
200
<a name="l00226"></a>00226 }
201
<a name="l00227"></a>00227
202
<a name="l00255"></a><a class="code" href="class_qwt_plot_curve.html#2de41014c2b87fd459d0c438a15dd33e">00255</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#2de41014c2b87fd459d0c438a15dd33e">QwtPlotCurve::setStyle</a>(<a class="code" href="class_qwt_plot_curve.html#15998aa80a11ba6ba80eebabaf773f70">CurveStyle</a> style)
203
<a name="l00256"></a>00256 {
204
<a name="l00257"></a>00257 <span class="keywordflow">if</span> ( style != d_data->style )
205
<a name="l00258"></a>00258 {
206
<a name="l00259"></a>00259 d_data->style = style;
207
<a name="l00260"></a>00260 <a class="code" href="class_qwt_plot_item.html#d956fdbce5b0721abccce6d09fe4d5ce">itemChanged</a>();
208
<a name="l00261"></a>00261 }
209
<a name="l00262"></a>00262 }
210
<a name="l00263"></a>00263
211
<a name="l00268"></a><a class="code" href="class_qwt_plot_curve.html#2df43bdea2a17118c9114d6fa774e598">00268</a> <a class="code" href="class_qwt_plot_curve.html#15998aa80a11ba6ba80eebabaf773f70">QwtPlotCurve::CurveStyle</a> <a class="code" href="class_qwt_plot_curve.html#2df43bdea2a17118c9114d6fa774e598">QwtPlotCurve::style</a>()<span class="keyword"> const </span>
212
<a name="l00269"></a>00269 <span class="keyword"></span>{
213
<a name="l00270"></a>00270 <span class="keywordflow">return</span> d_data->style;
214
<a name="l00271"></a>00271 }
215
<a name="l00272"></a>00272
216
<a name="l00278"></a><a class="code" href="class_qwt_plot_curve.html#f7ce6652d2ba981c19bddd1b6973bf94">00278</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#f7ce6652d2ba981c19bddd1b6973bf94">QwtPlotCurve::setSymbol</a>(<span class="keyword">const</span> <a class="code" href="class_qwt_symbol.html">QwtSymbol</a> &s )
217
<a name="l00279"></a>00279 {
218
<a name="l00280"></a>00280 d_data->sym = s;
219
<a name="l00281"></a>00281 <a class="code" href="class_qwt_plot_item.html#d956fdbce5b0721abccce6d09fe4d5ce">itemChanged</a>();
220
<a name="l00282"></a>00282 }
221
<a name="l00283"></a>00283
222
<a name="l00288"></a><a class="code" href="class_qwt_plot_curve.html#4278ed4f767e394b6f92ce4e5d25231a">00288</a> <span class="keyword">const</span> <a class="code" href="class_qwt_symbol.html">QwtSymbol</a> &<a class="code" href="class_qwt_plot_curve.html#4278ed4f767e394b6f92ce4e5d25231a">QwtPlotCurve::symbol</a>()<span class="keyword"> const </span>
223
<a name="l00289"></a>00289 <span class="keyword"></span>{
224
<a name="l00290"></a>00290 <span class="keywordflow">return</span> d_data->sym;
225
<a name="l00291"></a>00291 }
226
<a name="l00292"></a>00292
227
<a name="l00298"></a><a class="code" href="class_qwt_plot_curve.html#08328abaf2c3b67e479d1e485d2d0c4d">00298</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#08328abaf2c3b67e479d1e485d2d0c4d">QwtPlotCurve::setPen</a>(<span class="keyword">const</span> QPen &p)
228
<a name="l00299"></a>00299 {
229
<a name="l00300"></a>00300 <span class="keywordflow">if</span> ( p != d_data->pen )
230
<a name="l00301"></a>00301 {
231
<a name="l00302"></a>00302 d_data->pen = p;
232
<a name="l00303"></a>00303 <a class="code" href="class_qwt_plot_item.html#d956fdbce5b0721abccce6d09fe4d5ce">itemChanged</a>();
233
<a name="l00304"></a>00304 }
234
<a name="l00305"></a>00305 }
235
<a name="l00306"></a>00306
236
<a name="l00311"></a><a class="code" href="class_qwt_plot_curve.html#778aafd1385ce833821751d0a8635cef">00311</a> <span class="keyword">const</span> QPen& <a class="code" href="class_qwt_plot_curve.html#778aafd1385ce833821751d0a8635cef">QwtPlotCurve::pen</a>()<span class="keyword"> const </span>
237
<a name="l00312"></a>00312 <span class="keyword"></span>{
238
<a name="l00313"></a>00313 <span class="keywordflow">return</span> d_data->pen;
239
<a name="l00314"></a>00314 }
240
<a name="l00315"></a>00315
241
<a name="l00328"></a><a class="code" href="class_qwt_plot_curve.html#dc52ea882ec1f994e2d2e23c7465b0c2">00328</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#dc52ea882ec1f994e2d2e23c7465b0c2">QwtPlotCurve::setBrush</a>(<span class="keyword">const</span> QBrush &brush)
242
<a name="l00329"></a>00329 {
243
<a name="l00330"></a>00330 <span class="keywordflow">if</span> ( brush != d_data->brush )
244
<a name="l00331"></a>00331 {
245
<a name="l00332"></a>00332 d_data->brush = brush;
246
<a name="l00333"></a>00333 <a class="code" href="class_qwt_plot_item.html#d956fdbce5b0721abccce6d09fe4d5ce">itemChanged</a>();
247
<a name="l00334"></a>00334 }
248
<a name="l00335"></a>00335 }
249
<a name="l00336"></a>00336
250
<a name="l00341"></a><a class="code" href="class_qwt_plot_curve.html#72b678ebb8e4821c1f85351292ce5697">00341</a> <span class="keyword">const</span> QBrush& <a class="code" href="class_qwt_plot_curve.html#72b678ebb8e4821c1f85351292ce5697">QwtPlotCurve::brush</a>()<span class="keyword"> const </span>
251
<a name="l00342"></a>00342 <span class="keyword"></span>{
252
<a name="l00343"></a>00343 <span class="keywordflow">return</span> d_data->brush;
253
<a name="l00344"></a>00344 }
254
<a name="l00345"></a>00345
255
<a name="l00346"></a>00346
256
<a name="l00358"></a><a class="code" href="class_qwt_plot_curve.html#1dc2caaddb1733703b5fcfbe19f29fe8">00358</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#1dc2caaddb1733703b5fcfbe19f29fe8">QwtPlotCurve::setData</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> *xData, <span class="keyword">const</span> <span class="keywordtype">double</span> *yData, <span class="keywordtype">int</span> size)
257
<a name="l00359"></a>00359 {
258
<a name="l00360"></a>00360 <span class="keyword">delete</span> d_xy;
259
<a name="l00361"></a>00361 d_xy = <span class="keyword">new</span> <a class="code" href="class_qwt_array_data.html">QwtArrayData</a>(xData, yData, size);
260
<a name="l00362"></a>00362 <a class="code" href="class_qwt_plot_item.html#d956fdbce5b0721abccce6d09fe4d5ce">itemChanged</a>();
261
<a name="l00363"></a>00363 }
262
<a name="l00364"></a>00364
263
<a name="l00373"></a><a class="code" href="class_qwt_plot_curve.html#ee3452eaaba4fe13e7452319893c4a86">00373</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#1dc2caaddb1733703b5fcfbe19f29fe8">QwtPlotCurve::setData</a>(<span class="keyword">const</span> QwtArray<double> &xData,
264
<a name="l00374"></a>00374 <span class="keyword">const</span> QwtArray<double> &yData)
265
<a name="l00375"></a>00375 {
266
<a name="l00376"></a>00376 <span class="keyword">delete</span> d_xy;
267
<a name="l00377"></a>00377 d_xy = <span class="keyword">new</span> <a class="code" href="class_qwt_array_data.html">QwtArrayData</a>(xData, yData);
268
<a name="l00378"></a>00378 <a class="code" href="class_qwt_plot_item.html#d956fdbce5b0721abccce6d09fe4d5ce">itemChanged</a>();
269
<a name="l00379"></a>00379 }
270
<a name="l00380"></a>00380
271
<a name="l00387"></a>00387 <span class="preprocessor">#if QT_VERSION < 0x040000</span>
272
<a name="l00388"></a>00388 <span class="preprocessor"></span><span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#1dc2caaddb1733703b5fcfbe19f29fe8">QwtPlotCurve::setData</a>(<span class="keyword">const</span> QwtArray<QwtDoublePoint> &data)
273
<a name="l00389"></a>00389 <span class="preprocessor">#else</span>
274
<a name="l00390"></a><a class="code" href="class_qwt_plot_curve.html#fabee31ee9ea2c9b8526e5a8b7739e77">00390</a> <span class="preprocessor"></span><span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#1dc2caaddb1733703b5fcfbe19f29fe8">QwtPlotCurve::setData</a>(<span class="keyword">const</span> QPolygonF &data)
275
<a name="l00391"></a>00391 <span class="preprocessor">#endif</span>
276
<a name="l00392"></a>00392 <span class="preprocessor"></span>{
277
<a name="l00393"></a>00393 <span class="keyword">delete</span> d_xy;
278
<a name="l00394"></a>00394 d_xy = <span class="keyword">new</span> <a class="code" href="class_qwt_polygon_f_data.html">QwtPolygonFData</a>(data);
279
<a name="l00395"></a>00395 itemChanged();
280
<a name="l00396"></a>00396 }
281
<a name="l00397"></a>00397
282
<a name="l00404"></a><a class="code" href="class_qwt_plot_curve.html#4e9abd5034a175deef8e88a7f8ad41ca">00404</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#1dc2caaddb1733703b5fcfbe19f29fe8">QwtPlotCurve::setData</a>(<span class="keyword">const</span> <a class="code" href="class_qwt_data.html">QwtData</a> &data)
283
<a name="l00405"></a>00405 {
284
<a name="l00406"></a>00406 <span class="keyword">delete</span> d_xy;
285
<a name="l00407"></a>00407 d_xy = <a class="code" href="class_qwt_plot_curve.html#1e30b056439ea629f08e8a5f1055949d">data</a>.<a class="code" href="class_qwt_data.html#8531a1add1f0b2d12809f90f97fd80c9">copy</a>();
286
<a name="l00408"></a>00408 <a class="code" href="class_qwt_plot_item.html#d956fdbce5b0721abccce6d09fe4d5ce">itemChanged</a>();
287
<a name="l00409"></a>00409 }
288
<a name="l00410"></a>00410
289
<a name="l00424"></a><a class="code" href="class_qwt_plot_curve.html#35533bd778842cf45b283a2baf5ff4a4">00424</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#35533bd778842cf45b283a2baf5ff4a4">QwtPlotCurve::setRawData</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> *xData, <span class="keyword">const</span> <span class="keywordtype">double</span> *yData, <span class="keywordtype">int</span> size)
290
<a name="l00425"></a>00425 {
291
<a name="l00426"></a>00426 <span class="keyword">delete</span> d_xy;
292
<a name="l00427"></a>00427 d_xy = <span class="keyword">new</span> <a class="code" href="class_qwt_c_pointer_data.html">QwtCPointerData</a>(xData, yData, size);
293
<a name="l00428"></a>00428 <a class="code" href="class_qwt_plot_item.html#d956fdbce5b0721abccce6d09fe4d5ce">itemChanged</a>();
294
<a name="l00429"></a>00429 }
295
<a name="l00430"></a>00430
296
<a name="l00437"></a><a class="code" href="class_qwt_plot_curve.html#592742a3aa52a81bd9ea548e81a50f12">00437</a> QwtDoubleRect <a class="code" href="class_qwt_plot_curve.html#592742a3aa52a81bd9ea548e81a50f12">QwtPlotCurve::boundingRect</a>()<span class="keyword"> const</span>
297
<a name="l00438"></a>00438 <span class="keyword"></span>{
298
<a name="l00439"></a>00439 <span class="keywordflow">if</span> ( d_xy == NULL )
299
<a name="l00440"></a>00440 <span class="keywordflow">return</span> QwtDoubleRect(1.0, 1.0, -2.0, -2.0); <span class="comment">// invalid</span>
300
<a name="l00441"></a>00441
301
<a name="l00442"></a>00442 <span class="keywordflow">return</span> d_xy-><a class="code" href="class_qwt_data.html#d72b6842ce6af1f61f9643786d63a91f">boundingRect</a>();
302
<a name="l00443"></a>00443 }
303
<a name="l00444"></a>00444
304
<a name="l00454"></a><a class="code" href="class_qwt_plot_curve.html#8d52afdd1612ccb4dbf3f410886e680b">00454</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#8d52afdd1612ccb4dbf3f410886e680b">QwtPlotCurve::draw</a>(QPainter *painter,
305
<a name="l00455"></a>00455 <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &xMap, <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &yMap,
306
<a name="l00456"></a>00456 <span class="keyword">const</span> QRect &)<span class="keyword"> const</span>
307
<a name="l00457"></a>00457 <span class="keyword"></span>{
308
<a name="l00458"></a>00458 <a class="code" href="class_qwt_plot_curve.html#8d52afdd1612ccb4dbf3f410886e680b">draw</a>(painter, xMap, yMap, 0, -1);
309
<a name="l00459"></a>00459 }
310
<a name="l00460"></a>00460
311
<a name="l00478"></a><a class="code" href="class_qwt_plot_curve.html#57cabe79dbb0df094f5c337689ff88a0">00478</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#8d52afdd1612ccb4dbf3f410886e680b">QwtPlotCurve::draw</a>(<span class="keywordtype">int</span> from, <span class="keywordtype">int</span> to)<span class="keyword"> const</span>
312
<a name="l00479"></a>00479 <span class="keyword"></span>{
313
<a name="l00480"></a>00480 <span class="keywordflow">if</span> ( !<a class="code" href="class_qwt_plot_item.html#4c99653a14a49ad94d466168d06e97b9">plot</a>() )
314
<a name="l00481"></a>00481 <span class="keywordflow">return</span>;
315
<a name="l00482"></a>00482
316
<a name="l00483"></a>00483 <a class="code" href="class_qwt_plot_canvas.html">QwtPlotCanvas</a> *canvas = <a class="code" href="class_qwt_plot_item.html#4c99653a14a49ad94d466168d06e97b9">plot</a>()-><a class="code" href="class_qwt_plot.html#afcc82150034fbeb393ceb9f54ba2f1a">canvas</a>();
317
<a name="l00484"></a>00484
318
<a name="l00485"></a>00485 <span class="keywordtype">bool</span> directPaint = <span class="keyword">true</span>;
319
<a name="l00486"></a>00486
320
<a name="l00487"></a>00487 <span class="preprocessor">#if QT_VERSION >= 0x040000</span>
321
<a name="l00488"></a>00488 <span class="preprocessor"></span> <span class="keywordflow">if</span> ( !canvas->testAttribute(Qt::WA_WState_InPaintEvent) &&
322
<a name="l00489"></a>00489 !canvas->testAttribute(Qt::WA_PaintOutsidePaintEvent) )
323
<a name="l00490"></a>00490 {
324
<a name="l00491"></a>00491 <span class="comment">/*</span>
325
<a name="l00492"></a>00492 <span class="comment"> We save curve and range in helper and call repaint.</span>
326
<a name="l00493"></a>00493 <span class="comment"> The helper filters the Paint event, to repeat</span>
327
<a name="l00494"></a>00494 <span class="comment"> the QwtPlotCurve::draw, but now from inside the paint</span>
328
<a name="l00495"></a>00495 <span class="comment"> event.</span>
329
<a name="l00496"></a>00496 <span class="comment"> */</span>
330
<a name="l00497"></a>00497
331
<a name="l00498"></a>00498 QwtPlotCurvePaintHelper helper(<span class="keyword">this</span>, from, to);
332
<a name="l00499"></a>00499 canvas->installEventFilter(&helper);
333
<a name="l00500"></a>00500 canvas->repaint();
334
<a name="l00501"></a>00501
335
<a name="l00502"></a>00502 <span class="keywordflow">return</span>;
336
<a name="l00503"></a>00503 }
337
<a name="l00504"></a>00504 <span class="preprocessor">#endif</span>
338
<a name="l00505"></a>00505 <span class="preprocessor"></span>
339
<a name="l00506"></a>00506 <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> xMap = plot()->canvasMap(xAxis());
340
<a name="l00507"></a>00507 <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> yMap = plot()->canvasMap(yAxis());
341
<a name="l00508"></a>00508
342
<a name="l00509"></a>00509 <span class="keywordflow">if</span> ( canvas->testPaintAttribute(QwtPlotCanvas::PaintCached) &&
343
<a name="l00510"></a>00510 canvas->paintCache() && !canvas->paintCache()->isNull() )
344
<a name="l00511"></a>00511 {
345
<a name="l00512"></a>00512 QPainter cachePainter((QPixmap *)canvas->paintCache());
346
<a name="l00513"></a>00513 cachePainter.translate(-canvas->contentsRect().x(),
347
<a name="l00514"></a>00514 -canvas->contentsRect().y());
348
<a name="l00515"></a>00515
349
<a name="l00516"></a>00516 draw(&cachePainter, xMap, yMap, from, to);
350
<a name="l00517"></a>00517 }
351
<a name="l00518"></a>00518
352
<a name="l00519"></a>00519 <span class="keywordflow">if</span> ( directPaint )
353
<a name="l00520"></a>00520 {
354
<a name="l00521"></a>00521 QPainter painter(canvas);
355
<a name="l00522"></a>00522
356
<a name="l00523"></a>00523 painter.setClipping(<span class="keyword">true</span>);
357
<a name="l00524"></a>00524 painter.setClipRect(canvas->contentsRect());
358
<a name="l00525"></a>00525
359
<a name="l00526"></a>00526 draw(&painter, xMap, yMap, from, to);
360
<a name="l00527"></a>00527
361
<a name="l00528"></a>00528 <span class="keywordflow">return</span>;
362
<a name="l00529"></a>00529 }
363
<a name="l00530"></a>00530
364
<a name="l00531"></a>00531 <span class="preprocessor">#if QT_VERSION >= 0x040000</span>
365
<a name="l00532"></a>00532 <span class="preprocessor"></span> <span class="keywordflow">if</span> ( canvas->testPaintAttribute(QwtPlotCanvas::PaintCached) &&
366
<a name="l00533"></a>00533 canvas->paintCache() )
367
<a name="l00534"></a>00534 {
368
<a name="l00535"></a>00535 <span class="comment">/*</span>
369
<a name="l00536"></a>00536 <span class="comment"> The cache is up to date. We flush it via repaint to the</span>
370
<a name="l00537"></a>00537 <span class="comment"> canvas. This works flicker free but is much ( > 10x )</span>
371
<a name="l00538"></a>00538 <span class="comment"> slower than direct painting.</span>
372
<a name="l00539"></a>00539 <span class="comment"> */</span>
373
<a name="l00540"></a>00540
374
<a name="l00541"></a>00541 <span class="keyword">const</span> <span class="keywordtype">bool</span> noBG = canvas->testAttribute(Qt::WA_NoBackground);
375
<a name="l00542"></a>00542 <span class="keywordflow">if</span> ( !noBG )
376
<a name="l00543"></a>00543 canvas->setAttribute(Qt::WA_NoBackground, <span class="keyword">true</span>);
377
<a name="l00544"></a>00544
378
<a name="l00545"></a>00545 canvas->repaint(canvas->contentsRect());
379
<a name="l00546"></a>00546
380
<a name="l00547"></a>00547 <span class="keywordflow">if</span> ( !noBG )
381
<a name="l00548"></a>00548 canvas->setAttribute(Qt::WA_NoBackground, <span class="keyword">false</span>);
382
<a name="l00549"></a>00549
383
<a name="l00550"></a>00550 <span class="keywordflow">return</span>;
384
<a name="l00551"></a>00551 }
385
<a name="l00552"></a>00552 <span class="preprocessor">#endif</span>
386
<a name="l00553"></a>00553 <span class="preprocessor"></span>
387
<a name="l00554"></a>00554 <span class="comment">// Ok, we give up </span>
388
<a name="l00555"></a>00555 canvas->repaint(canvas->contentsRect());
389
<a name="l00556"></a>00556 }
390
<a name="l00557"></a>00557
391
<a name="l00569"></a><a class="code" href="class_qwt_plot_curve.html#517b93ce008faddb49e706b882f44474">00569</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#8d52afdd1612ccb4dbf3f410886e680b">QwtPlotCurve::draw</a>(QPainter *painter,
392
<a name="l00570"></a>00570 <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &xMap, <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &yMap,
393
<a name="l00571"></a>00571 <span class="keywordtype">int</span> from, <span class="keywordtype">int</span> to)<span class="keyword"> const</span>
394
<a name="l00572"></a>00572 <span class="keyword"></span>{
395
<a name="l00573"></a>00573 <span class="keywordflow">if</span> ( !painter || <a class="code" href="class_qwt_plot_curve.html#261170c51a8e6853f333c76c501992b7">dataSize</a>() <= 0 )
396
<a name="l00574"></a>00574 <span class="keywordflow">return</span>;
397
<a name="l00575"></a>00575
398
<a name="l00576"></a>00576 <span class="keywordflow">if</span> (to < 0)
399
<a name="l00577"></a>00577 to = <a class="code" href="class_qwt_plot_curve.html#261170c51a8e6853f333c76c501992b7">dataSize</a>() - 1;
400
<a name="l00578"></a>00578
401
<a name="l00579"></a>00579 <span class="keywordflow">if</span> ( verifyRange(<a class="code" href="class_qwt_plot_curve.html#261170c51a8e6853f333c76c501992b7">dataSize</a>(), from, to) > 0 )
402
<a name="l00580"></a>00580 {
403
<a name="l00581"></a>00581 painter->save();
404
<a name="l00582"></a>00582 painter->setPen(d_data->pen);
405
<a name="l00583"></a>00583
406
<a name="l00584"></a>00584 <span class="comment">/*</span>
407
<a name="l00585"></a>00585 <span class="comment"> Qt 4.0.0 is slow when drawing lines, but it´s even </span>
408
<a name="l00586"></a>00586 <span class="comment"> slower when the painter has a brush. So we don't</span>
409
<a name="l00587"></a>00587 <span class="comment"> set the brush before we really need it.</span>
410
<a name="l00588"></a>00588 <span class="comment"> */</span>
411
<a name="l00589"></a>00589
412
<a name="l00590"></a>00590 <a class="code" href="class_qwt_plot_curve.html#cb4e2f26df075483bf6105bb5f2f74fc">drawCurve</a>(painter, d_data->style, xMap, yMap, from, to);
413
<a name="l00591"></a>00591 painter->restore();
414
<a name="l00592"></a>00592
415
<a name="l00593"></a>00593 <span class="keywordflow">if</span> (d_data->sym.style() != QwtSymbol::NoSymbol)
416
<a name="l00594"></a>00594 {
417
<a name="l00595"></a>00595 painter->save();
418
<a name="l00596"></a>00596 <a class="code" href="class_qwt_plot_curve.html#b16f5a4329291305c267beab1a6d2dfe">drawSymbols</a>(painter, d_data->sym, xMap, yMap, from, to);
419
<a name="l00597"></a>00597 painter->restore();
420
<a name="l00598"></a>00598 }
421
<a name="l00599"></a>00599 }
422
<a name="l00600"></a>00600 }
423
<a name="l00601"></a>00601
424
<a name="l00613"></a><a class="code" href="class_qwt_plot_curve.html#cb4e2f26df075483bf6105bb5f2f74fc">00613</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#cb4e2f26df075483bf6105bb5f2f74fc">QwtPlotCurve::drawCurve</a>(QPainter *painter, <span class="keywordtype">int</span> style,
425
<a name="l00614"></a>00614 <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &xMap, <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &yMap,
426
<a name="l00615"></a>00615 <span class="keywordtype">int</span> from, <span class="keywordtype">int</span> to)<span class="keyword"> const</span>
427
<a name="l00616"></a>00616 <span class="keyword"></span>{
428
<a name="l00617"></a>00617 <span class="keywordflow">switch</span> (style)
429
<a name="l00618"></a>00618 {
430
<a name="l00619"></a>00619 <span class="keywordflow">case</span> Lines:
431
<a name="l00620"></a>00620 <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_plot_curve.html#0dc5e6af9ec33a1b54e3c3041c00b939">testCurveAttribute</a>(Fitted) )
432
<a name="l00621"></a>00621 {
433
<a name="l00622"></a>00622 <span class="comment">// we always need the complete </span>
434
<a name="l00623"></a>00623 <span class="comment">// curve for fitting</span>
435
<a name="l00624"></a>00624 from = 0;
436
<a name="l00625"></a>00625 to = <a class="code" href="class_qwt_plot_curve.html#261170c51a8e6853f333c76c501992b7">dataSize</a>() - 1;
437
<a name="l00626"></a>00626 }
438
<a name="l00627"></a>00627 <a class="code" href="class_qwt_plot_curve.html#66fb80deaa39c0b7c70b2914dc74d194">drawLines</a>(painter, xMap, yMap, from, to);
439
<a name="l00628"></a>00628 <span class="keywordflow">break</span>;
440
<a name="l00629"></a>00629 <span class="keywordflow">case</span> Sticks:
441
<a name="l00630"></a>00630 <a class="code" href="class_qwt_plot_curve.html#64062381af95034c9d590517bd4d7bfb">drawSticks</a>(painter, xMap, yMap, from, to);
442
<a name="l00631"></a>00631 <span class="keywordflow">break</span>;
443
<a name="l00632"></a>00632 <span class="keywordflow">case</span> Steps:
444
<a name="l00633"></a>00633 <a class="code" href="class_qwt_plot_curve.html#46fe8d36454bc19b71615e3df96aa2e9">drawSteps</a>(painter, xMap, yMap, from, to);
445
<a name="l00634"></a>00634 <span class="keywordflow">break</span>;
446
<a name="l00635"></a>00635 <span class="keywordflow">case</span> Dots:
447
<a name="l00636"></a>00636 <a class="code" href="class_qwt_plot_curve.html#6fcda40f4bd62fb3a91017ed9e7e49dc">drawDots</a>(painter, xMap, yMap, from, to);
448
<a name="l00637"></a>00637 <span class="keywordflow">break</span>;
449
<a name="l00638"></a>00638 <span class="keywordflow">case</span> NoCurve:
450
<a name="l00639"></a>00639 <span class="keywordflow">default</span>:
451
<a name="l00640"></a>00640 <span class="keywordflow">break</span>;
452
<a name="l00641"></a>00641 }
453
<a name="l00642"></a>00642 }
454
<a name="l00643"></a>00643
455
<a name="l00659"></a><a class="code" href="class_qwt_plot_curve.html#66fb80deaa39c0b7c70b2914dc74d194">00659</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#66fb80deaa39c0b7c70b2914dc74d194">QwtPlotCurve::drawLines</a>(QPainter *painter,
456
<a name="l00660"></a>00660 <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &xMap, <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &yMap,
457
<a name="l00661"></a>00661 <span class="keywordtype">int</span> from, <span class="keywordtype">int</span> to)<span class="keyword"> const</span>
458
<a name="l00662"></a>00662 <span class="keyword"></span>{
459
<a name="l00663"></a>00663 <span class="keywordtype">int</span> size = to - from + 1;
460
<a name="l00664"></a>00664 <span class="keywordflow">if</span> ( size <= 0 )
461
<a name="l00665"></a>00665 <span class="keywordflow">return</span>;
462
<a name="l00666"></a>00666
463
<a name="l00667"></a>00667 QwtPolygon polyline;
464
<a name="l00668"></a>00668 <span class="keywordflow">if</span> ( ( d_data->attributes & Fitted ) && d_data->curveFitter )
465
<a name="l00669"></a>00669 {
466
<a name="l00670"></a>00670 <span class="comment">// Transform x and y values to window coordinates</span>
467
<a name="l00671"></a>00671 <span class="comment">// to avoid a distinction between linear and</span>
468
<a name="l00672"></a>00672 <span class="comment">// logarithmic scales.</span>
469
<a name="l00673"></a>00673
470
<a name="l00674"></a>00674 <span class="preprocessor">#if QT_VERSION < 0x040000</span>
471
<a name="l00675"></a>00675 <span class="preprocessor"></span> QwtArray<QwtDoublePoint> points(size);
472
<a name="l00676"></a>00676 <span class="preprocessor">#else</span>
473
<a name="l00677"></a>00677 <span class="preprocessor"></span> QPolygonF points(size);
474
<a name="l00678"></a>00678 <span class="preprocessor">#endif</span>
475
<a name="l00679"></a>00679 <span class="preprocessor"></span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = from; i <= to; i++)
476
<a name="l00680"></a>00680 {
477
<a name="l00681"></a>00681 QwtDoublePoint &p = points[i];
478
<a name="l00682"></a>00682 p.setX( xMap.<a class="code" href="class_qwt_scale_map.html#053cad00dd463f45c7e1591c9f2d8296">xTransform</a>(<a class="code" href="class_qwt_plot_curve.html#312b1fe8635430c293ee8fdc9fcfd774">x</a>(i)) );
479
<a name="l00683"></a>00683 p.setY( yMap.<a class="code" href="class_qwt_scale_map.html#053cad00dd463f45c7e1591c9f2d8296">xTransform</a>(<a class="code" href="class_qwt_plot_curve.html#db2885f90bfe2ce1f83929a20dffc38e">y</a>(i)) );
480
<a name="l00684"></a>00684 }
481
<a name="l00685"></a>00685
482
<a name="l00686"></a>00686 points = d_data->curveFitter->fitCurve(points);
483
<a name="l00687"></a>00687 size = points.size();
484
<a name="l00688"></a>00688
485
<a name="l00689"></a>00689 <span class="keywordflow">if</span> ( size == 0 )
486
<a name="l00690"></a>00690 <span class="keywordflow">return</span>;
487
<a name="l00691"></a>00691
488
<a name="l00692"></a>00692 <span class="comment">// Round QwtDoublePoints to QPoints</span>
489
<a name="l00693"></a>00693 <span class="comment">// When Qwt support for Qt3 has been dropped (Qwt 6.x)</span>
490
<a name="l00694"></a>00694 <span class="comment">// we will use a doubles for painting and the following</span>
491
<a name="l00695"></a>00695 <span class="comment">// step will be obsolete.</span>
492
<a name="l00696"></a>00696
493
<a name="l00697"></a>00697 polyline.resize(size);
494
<a name="l00698"></a>00698
495
<a name="l00699"></a>00699 <span class="keyword">const</span> QwtDoublePoint *p = points.data();
496
<a name="l00700"></a>00700 QPoint *pl = polyline.data();
497
<a name="l00701"></a>00701 <span class="keywordflow">if</span> ( d_data->paintAttributes & PaintFiltered )
498
<a name="l00702"></a>00702 {
499
<a name="l00703"></a>00703
500
<a name="l00704"></a>00704 QPoint pp(qRound(p[0].<a class="code" href="class_qwt_plot_curve.html#312b1fe8635430c293ee8fdc9fcfd774">x</a>()), qRound(p[0].<a class="code" href="class_qwt_plot_curve.html#db2885f90bfe2ce1f83929a20dffc38e">y</a>()));
501
<a name="l00705"></a>00705 pl[0] = pp;
502
<a name="l00706"></a>00706
503
<a name="l00707"></a>00707 <span class="keywordtype">int</span> count = 1;
504
<a name="l00708"></a>00708 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i < size; i++)
505
<a name="l00709"></a>00709 {
506
<a name="l00710"></a>00710 <span class="keyword">const</span> QPoint pi(qRound(p[i].<a class="code" href="class_qwt_plot_curve.html#312b1fe8635430c293ee8fdc9fcfd774">x</a>()), qRound(p[i].<a class="code" href="class_qwt_plot_curve.html#db2885f90bfe2ce1f83929a20dffc38e">y</a>()));
507
<a name="l00711"></a>00711 <span class="keywordflow">if</span> ( pi != pp )
508
<a name="l00712"></a>00712 {
509
<a name="l00713"></a>00713 pl[count++] = pi;
510
<a name="l00714"></a>00714 pp = pi;
511
<a name="l00715"></a>00715 }
512
<a name="l00716"></a>00716 }
513
<a name="l00717"></a>00717 <span class="keywordflow">if</span> ( count != size )
514
<a name="l00718"></a>00718 polyline.resize(count);
515
<a name="l00719"></a>00719 }
516
<a name="l00720"></a>00720 <span class="keywordflow">else</span>
517
<a name="l00721"></a>00721 {
518
<a name="l00722"></a>00722 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < size; i++ )
519
<a name="l00723"></a>00723 {
520
<a name="l00724"></a>00724 pl[i].setX( qRound(p[i].x()) );
521
<a name="l00725"></a>00725 pl[i].setY( qRound(p[i].y()) );
522
<a name="l00726"></a>00726 }
523
<a name="l00727"></a>00727 }
524
<a name="l00728"></a>00728 }
525
<a name="l00729"></a>00729 <span class="keywordflow">else</span>
526
<a name="l00730"></a>00730 {
527
<a name="l00731"></a>00731 polyline.resize(size);
528
<a name="l00732"></a>00732
529
<a name="l00733"></a>00733 <span class="keywordflow">if</span> ( d_data->paintAttributes & PaintFiltered )
530
<a name="l00734"></a>00734 {
531
<a name="l00735"></a>00735 QPoint pp( xMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(x(from)), yMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(y(from)) );
532
<a name="l00736"></a>00736 polyline.setPoint(0, pp);
533
<a name="l00737"></a>00737
534
<a name="l00738"></a>00738 <span class="keywordtype">int</span> count = 1;
535
<a name="l00739"></a>00739 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = from + 1; i <= to; i++)
536
<a name="l00740"></a>00740 {
537
<a name="l00741"></a>00741 <span class="keyword">const</span> QPoint pi(xMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(x(i)), yMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(y(i)));
538
<a name="l00742"></a>00742 <span class="keywordflow">if</span> ( pi != pp )
539
<a name="l00743"></a>00743 {
540
<a name="l00744"></a>00744 polyline.setPoint(count, pi);
541
<a name="l00745"></a>00745 count++;
542
<a name="l00746"></a>00746
543
<a name="l00747"></a>00747 pp = pi;
544
<a name="l00748"></a>00748 }
545
<a name="l00749"></a>00749 }
546
<a name="l00750"></a>00750 <span class="keywordflow">if</span> ( count != size )
547
<a name="l00751"></a>00751 polyline.resize(count);
548
<a name="l00752"></a>00752 }
549
<a name="l00753"></a>00753 <span class="keywordflow">else</span>
550
<a name="l00754"></a>00754 {
551
<a name="l00755"></a>00755 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = from; i <= to; i++)
552
<a name="l00756"></a>00756 {
553
<a name="l00757"></a>00757 <span class="keywordtype">int</span> xi = xMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(x(i));
554
<a name="l00758"></a>00758 <span class="keywordtype">int</span> yi = yMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(y(i));
555
<a name="l00759"></a>00759
556
<a name="l00760"></a>00760 polyline.setPoint(i - from, xi, yi);
557
<a name="l00761"></a>00761 }
558
<a name="l00762"></a>00762 }
559
<a name="l00763"></a>00763 }
560
<a name="l00764"></a>00764
561
<a name="l00765"></a>00765 <span class="keywordflow">if</span> ( d_data->paintAttributes & ClipPolygons )
562
<a name="l00766"></a>00766 {
563
<a name="l00767"></a>00767 <a class="code" href="class_qwt_rect.html">QwtRect</a> r = painter->window();
564
<a name="l00768"></a>00768 polyline = r.<a class="code" href="class_qwt_rect.html#89bfabf3416a3b535451a83e91a12d13">clip</a>(polyline);
565
<a name="l00769"></a>00769 }
566
<a name="l00770"></a>00770
567
<a name="l00771"></a>00771 <a class="code" href="class_qwt_painter.html#fec384335c12a3cf84d82cbeb30cd537">QwtPainter::drawPolyline</a>(painter, polyline);
568
<a name="l00772"></a>00772
569
<a name="l00773"></a>00773 <span class="keywordflow">if</span> ( d_data->brush.style() != Qt::NoBrush )
570
<a name="l00774"></a>00774 fillCurve(painter, xMap, yMap, polyline);
571
<a name="l00775"></a>00775 }
572
<a name="l00776"></a>00776
573
<a name="l00788"></a><a class="code" href="class_qwt_plot_curve.html#64062381af95034c9d590517bd4d7bfb">00788</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#64062381af95034c9d590517bd4d7bfb">QwtPlotCurve::drawSticks</a>(QPainter *painter,
574
<a name="l00789"></a>00789 <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &xMap, <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &yMap,
575
<a name="l00790"></a>00790 <span class="keywordtype">int</span> from, <span class="keywordtype">int</span> to)<span class="keyword"> const</span>
576
<a name="l00791"></a>00791 <span class="keyword"></span>{
577
<a name="l00792"></a>00792 <span class="keywordtype">int</span> x0 = xMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(d_data->reference);
578
<a name="l00793"></a>00793 <span class="keywordtype">int</span> y0 = yMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(d_data->reference);
579
<a name="l00794"></a>00794
580
<a name="l00795"></a>00795 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = from; i <= to; i++)
581
<a name="l00796"></a>00796 {
582
<a name="l00797"></a>00797 <span class="keyword">const</span> <span class="keywordtype">int</span> xi = xMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(<a class="code" href="class_qwt_plot_curve.html#312b1fe8635430c293ee8fdc9fcfd774">x</a>(i));
583
<a name="l00798"></a>00798 <span class="keyword">const</span> <span class="keywordtype">int</span> yi = yMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(<a class="code" href="class_qwt_plot_curve.html#db2885f90bfe2ce1f83929a20dffc38e">y</a>(i));
584
<a name="l00799"></a>00799
585
<a name="l00800"></a>00800 <span class="keywordflow">if</span> (d_data->attributes & Xfy)
586
<a name="l00801"></a>00801 <a class="code" href="class_qwt_painter.html#f809f23704df7e05f51222daa296ca80">QwtPainter::drawLine</a>(painter, x0, yi, xi, yi);
587
<a name="l00802"></a>00802 <span class="keywordflow">else</span>
588
<a name="l00803"></a>00803 <a class="code" href="class_qwt_painter.html#f809f23704df7e05f51222daa296ca80">QwtPainter::drawLine</a>(painter, xi, y0, xi, yi);
589
<a name="l00804"></a>00804 }
590
<a name="l00805"></a>00805 }
591
<a name="l00806"></a>00806
592
<a name="l00818"></a><a class="code" href="class_qwt_plot_curve.html#6fcda40f4bd62fb3a91017ed9e7e49dc">00818</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#6fcda40f4bd62fb3a91017ed9e7e49dc">QwtPlotCurve::drawDots</a>(QPainter *painter,
593
<a name="l00819"></a>00819 <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &xMap, <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &yMap,
594
<a name="l00820"></a>00820 <span class="keywordtype">int</span> from, <span class="keywordtype">int</span> to)<span class="keyword"> const</span>
595
<a name="l00821"></a>00821 <span class="keyword"></span>{
596
<a name="l00822"></a>00822 <span class="keyword">const</span> QRect window = painter->window();
597
<a name="l00823"></a>00823 <span class="keywordflow">if</span> ( window.isEmpty() )
598
<a name="l00824"></a>00824 <span class="keywordflow">return</span>;
599
<a name="l00825"></a>00825
600
<a name="l00826"></a>00826 <span class="keyword">const</span> <span class="keywordtype">bool</span> doFill = d_data->brush.style() != Qt::NoBrush;
601
<a name="l00827"></a>00827
602
<a name="l00828"></a>00828 QwtPolygon polyline;
603
<a name="l00829"></a>00829 <span class="keywordflow">if</span> ( doFill )
604
<a name="l00830"></a>00830 polyline.resize(to - from + 1);
605
<a name="l00831"></a>00831
606
<a name="l00832"></a>00832 <span class="keywordflow">if</span> ( to > from && d_data->paintAttributes & PaintFiltered )
607
<a name="l00833"></a>00833 {
608
<a name="l00834"></a>00834 <span class="keywordflow">if</span> ( doFill )
609
<a name="l00835"></a>00835 {
610
<a name="l00836"></a>00836 QPoint pp( xMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(<a class="code" href="class_qwt_plot_curve.html#312b1fe8635430c293ee8fdc9fcfd774">x</a>(from)), yMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(<a class="code" href="class_qwt_plot_curve.html#db2885f90bfe2ce1f83929a20dffc38e">y</a>(from)) );
611
<a name="l00837"></a>00837
612
<a name="l00838"></a>00838 <a class="code" href="class_qwt_painter.html#f75e34851777099b742910612e8e4b39">QwtPainter::drawPoint</a>(painter, pp.x(), pp.y());
613
<a name="l00839"></a>00839 polyline.setPoint(0, pp);
614
<a name="l00840"></a>00840
615
<a name="l00841"></a>00841 <span class="keywordtype">int</span> count = 1;
616
<a name="l00842"></a>00842 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = from + 1; i <= to; i++)
617
<a name="l00843"></a>00843 {
618
<a name="l00844"></a>00844 <span class="keyword">const</span> QPoint pi(xMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(<a class="code" href="class_qwt_plot_curve.html#312b1fe8635430c293ee8fdc9fcfd774">x</a>(i)), yMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(<a class="code" href="class_qwt_plot_curve.html#db2885f90bfe2ce1f83929a20dffc38e">y</a>(i)));
619
<a name="l00845"></a>00845 <span class="keywordflow">if</span> ( pi != pp )
620
<a name="l00846"></a>00846 {
621
<a name="l00847"></a>00847 <a class="code" href="class_qwt_painter.html#f75e34851777099b742910612e8e4b39">QwtPainter::drawPoint</a>(painter, pi.x(), pi.y());
622
<a name="l00848"></a>00848
623
<a name="l00849"></a>00849 polyline.setPoint(count, pi);
624
<a name="l00850"></a>00850 count++;
625
<a name="l00851"></a>00851
626
<a name="l00852"></a>00852 pp = pi;
627
<a name="l00853"></a>00853 }
628
<a name="l00854"></a>00854 }
629
<a name="l00855"></a>00855 <span class="keywordflow">if</span> ( <span class="keywordtype">int</span>(polyline.size()) != count )
630
<a name="l00856"></a>00856 polyline.resize(count);
631
<a name="l00857"></a>00857 }
632
<a name="l00858"></a>00858 <span class="keywordflow">else</span>
633
<a name="l00859"></a>00859 {
634
<a name="l00860"></a>00860 <span class="comment">// if we don't need to fill, we can sort out</span>
635
<a name="l00861"></a>00861 <span class="comment">// duplicates independent from the order</span>
636
<a name="l00862"></a>00862
637
<a name="l00863"></a>00863 PrivateData::PixelMatrix pixelMatrix(window);
638
<a name="l00864"></a>00864
639
<a name="l00865"></a>00865 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = from; i <= to; i++)
640
<a name="l00866"></a>00866 {
641
<a name="l00867"></a>00867 <span class="keyword">const</span> QPoint p( xMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(<a class="code" href="class_qwt_plot_curve.html#312b1fe8635430c293ee8fdc9fcfd774">x</a>(i)),
642
<a name="l00868"></a>00868 yMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(<a class="code" href="class_qwt_plot_curve.html#db2885f90bfe2ce1f83929a20dffc38e">y</a>(i)) );
643
<a name="l00869"></a>00869
644
<a name="l00870"></a>00870 <span class="keywordflow">if</span> ( pixelMatrix.testPixel(p) )
645
<a name="l00871"></a>00871 <a class="code" href="class_qwt_painter.html#f75e34851777099b742910612e8e4b39">QwtPainter::drawPoint</a>(painter, p.x(), p.y());
646
<a name="l00872"></a>00872 }
647
<a name="l00873"></a>00873 }
648
<a name="l00874"></a>00874 }
649
<a name="l00875"></a>00875 <span class="keywordflow">else</span>
650
<a name="l00876"></a>00876 {
651
<a name="l00877"></a>00877 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = from; i <= to; i++)
652
<a name="l00878"></a>00878 {
653
<a name="l00879"></a>00879 <span class="keyword">const</span> <span class="keywordtype">int</span> xi = xMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(x(i));
654
<a name="l00880"></a>00880 <span class="keyword">const</span> <span class="keywordtype">int</span> yi = yMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(y(i));
655
<a name="l00881"></a>00881 <a class="code" href="class_qwt_painter.html#f75e34851777099b742910612e8e4b39">QwtPainter::drawPoint</a>(painter, xi, yi);
656
<a name="l00882"></a>00882
657
<a name="l00883"></a>00883 <span class="keywordflow">if</span> ( doFill )
658
<a name="l00884"></a>00884 polyline.setPoint(i - from, xi, yi);
659
<a name="l00885"></a>00885 }
660
<a name="l00886"></a>00886 }
661
<a name="l00887"></a>00887
662
<a name="l00888"></a>00888 <span class="keywordflow">if</span> ( doFill )
663
<a name="l00889"></a>00889 {
664
<a name="l00890"></a>00890 <span class="keywordflow">if</span> ( d_data->paintAttributes & ClipPolygons )
665
<a name="l00891"></a>00891 {
666
<a name="l00892"></a>00892 <span class="keyword">const</span> <a class="code" href="class_qwt_rect.html">QwtRect</a> r = painter->window();
667
<a name="l00893"></a>00893 polyline = r.<a class="code" href="class_qwt_rect.html#89bfabf3416a3b535451a83e91a12d13">clip</a>(polyline);
668
<a name="l00894"></a>00894 }
669
<a name="l00895"></a>00895
670
<a name="l00896"></a>00896 fillCurve(painter, xMap, yMap, polyline);
671
<a name="l00897"></a>00897 }
672
<a name="l00898"></a>00898 }
673
<a name="l00899"></a>00899
674
<a name="l00914"></a><a class="code" href="class_qwt_plot_curve.html#46fe8d36454bc19b71615e3df96aa2e9">00914</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#46fe8d36454bc19b71615e3df96aa2e9">QwtPlotCurve::drawSteps</a>(QPainter *painter,
675
<a name="l00915"></a>00915 <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &xMap, <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &yMap,
676
<a name="l00916"></a>00916 <span class="keywordtype">int</span> from, <span class="keywordtype">int</span> to)<span class="keyword"> const</span>
677
<a name="l00917"></a>00917 <span class="keyword"></span>{
678
<a name="l00918"></a>00918 QwtPolygon polyline(2 * (to - from) + 1);
679
<a name="l00919"></a>00919
680
<a name="l00920"></a>00920 <span class="keywordtype">bool</span> inverted = d_data->attributes & Yfx;
681
<a name="l00921"></a>00921 <span class="keywordflow">if</span> ( d_data->attributes & Inverted )
682
<a name="l00922"></a>00922 inverted = !inverted;
683
<a name="l00923"></a>00923
684
<a name="l00924"></a>00924 <span class="keywordtype">int</span> i,ip;
685
<a name="l00925"></a>00925 <span class="keywordflow">for</span> (i = from, ip = 0; i <= to; i++, ip += 2)
686
<a name="l00926"></a>00926 {
687
<a name="l00927"></a>00927 <span class="keyword">const</span> <span class="keywordtype">int</span> xi = xMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(<a class="code" href="class_qwt_plot_curve.html#312b1fe8635430c293ee8fdc9fcfd774">x</a>(i));
688
<a name="l00928"></a>00928 <span class="keyword">const</span> <span class="keywordtype">int</span> yi = yMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(<a class="code" href="class_qwt_plot_curve.html#db2885f90bfe2ce1f83929a20dffc38e">y</a>(i));
689
<a name="l00929"></a>00929
690
<a name="l00930"></a>00930 <span class="keywordflow">if</span> ( ip > 0 )
691
<a name="l00931"></a>00931 {
692
<a name="l00932"></a>00932 <span class="keywordflow">if</span> (inverted)
693
<a name="l00933"></a>00933 polyline.setPoint(ip - 1, polyline[ip-2].<a class="code" href="class_qwt_plot_curve.html#312b1fe8635430c293ee8fdc9fcfd774">x</a>(), yi);
694
<a name="l00934"></a>00934 <span class="keywordflow">else</span>
695
<a name="l00935"></a>00935 polyline.setPoint(ip - 1, xi, polyline[ip-2].<a class="code" href="class_qwt_plot_curve.html#db2885f90bfe2ce1f83929a20dffc38e">y</a>());
696
<a name="l00936"></a>00936 }
697
<a name="l00937"></a>00937
698
<a name="l00938"></a>00938 polyline.setPoint(ip, xi, yi);
699
<a name="l00939"></a>00939 }
700
<a name="l00940"></a>00940
701
<a name="l00941"></a>00941 <span class="keywordflow">if</span> ( d_data->paintAttributes & ClipPolygons )
702
<a name="l00942"></a>00942 {
703
<a name="l00943"></a>00943 <span class="keyword">const</span> <a class="code" href="class_qwt_rect.html">QwtRect</a> r = painter->window();
704
<a name="l00944"></a>00944 polyline = r.<a class="code" href="class_qwt_rect.html#89bfabf3416a3b535451a83e91a12d13">clip</a>(polyline);
705
<a name="l00945"></a>00945 }
706
<a name="l00946"></a>00946
707
<a name="l00947"></a>00947 <a class="code" href="class_qwt_painter.html#fec384335c12a3cf84d82cbeb30cd537">QwtPainter::drawPolyline</a>(painter, polyline);
708
<a name="l00948"></a>00948
709
<a name="l00949"></a>00949 <span class="keywordflow">if</span> ( d_data->brush.style() != Qt::NoBrush )
710
<a name="l00950"></a>00950 fillCurve(painter, xMap, yMap, polyline);
711
<a name="l00951"></a>00951 }
712
<a name="l00952"></a>00952
713
<a name="l00953"></a>00953
714
<a name="l00976"></a><a class="code" href="class_qwt_plot_curve.html#6ac9243e280f96cd149102a91271a473">00976</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#6ac9243e280f96cd149102a91271a473">QwtPlotCurve::setCurveAttribute</a>(<a class="code" href="class_qwt_plot_curve.html#38064f7de6f026a49db782c365f872c3">CurveAttribute</a> attribute, <span class="keywordtype">bool</span> on)
715
<a name="l00977"></a>00977 {
716
<a name="l00978"></a>00978 <span class="keywordflow">if</span> ( <span class="keywordtype">bool</span>(d_data->attributes & attribute) == on )
717
<a name="l00979"></a>00979 <span class="keywordflow">return</span>;
718
<a name="l00980"></a>00980
719
<a name="l00981"></a>00981 <span class="keywordflow">if</span> ( on )
720
<a name="l00982"></a>00982 d_data->attributes |= attribute;
721
<a name="l00983"></a>00983 <span class="keywordflow">else</span>
722
<a name="l00984"></a>00984 d_data->attributes &= ~attribute;
723
<a name="l00985"></a>00985
724
<a name="l00986"></a>00986 <a class="code" href="class_qwt_plot_item.html#d956fdbce5b0721abccce6d09fe4d5ce">itemChanged</a>();
725
<a name="l00987"></a>00987 }
726
<a name="l00988"></a>00988
727
<a name="l00993"></a><a class="code" href="class_qwt_plot_curve.html#0dc5e6af9ec33a1b54e3c3041c00b939">00993</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot_curve.html#0dc5e6af9ec33a1b54e3c3041c00b939">QwtPlotCurve::testCurveAttribute</a>(<a class="code" href="class_qwt_plot_curve.html#38064f7de6f026a49db782c365f872c3">CurveAttribute</a> attribute)<span class="keyword"> const </span>
728
<a name="l00994"></a>00994 <span class="keyword"></span>{
729
<a name="l00995"></a>00995 <span class="keywordflow">return</span> d_data->attributes & attribute;
730
<a name="l00996"></a>00996 }
731
<a name="l00997"></a>00997
732
<a name="l01014"></a><a class="code" href="class_qwt_plot_curve.html#ca451fa4a6d56c362bde659bb7b0f9b4">01014</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#ca451fa4a6d56c362bde659bb7b0f9b4">QwtPlotCurve::setCurveType</a>(<a class="code" href="class_qwt_plot_curve.html#c173d5059500d1c783602e33689714f5">CurveType</a> curveType)
733
<a name="l01015"></a>01015 {
734
<a name="l01016"></a>01016 <span class="keywordflow">if</span> ( d_data->curveType != curveType )
735
<a name="l01017"></a>01017 {
736
<a name="l01018"></a>01018 d_data->curveType = curveType;
737
<a name="l01019"></a>01019 <a class="code" href="class_qwt_plot_item.html#d956fdbce5b0721abccce6d09fe4d5ce">itemChanged</a>();
738
<a name="l01020"></a>01020 }
739
<a name="l01021"></a>01021 }
740
<a name="l01022"></a>01022
741
<a name="l01027"></a><a class="code" href="class_qwt_plot_curve.html#203a29e61eda8434826a12f14db96255">01027</a> <a class="code" href="class_qwt_plot_curve.html#c173d5059500d1c783602e33689714f5">QwtPlotCurve::CurveType</a> <a class="code" href="class_qwt_plot_curve.html#203a29e61eda8434826a12f14db96255">QwtPlotCurve::curveType</a>()<span class="keyword"> const</span>
742
<a name="l01028"></a>01028 <span class="keyword"></span>{
743
<a name="l01029"></a>01029 <span class="keywordflow">return</span> d_data->curveType;
744
<a name="l01030"></a>01030 }
745
<a name="l01031"></a>01031
746
<a name="l01032"></a><a class="code" href="class_qwt_plot_curve.html#c15588c78d175906a30de501b4dd7957">01032</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#c15588c78d175906a30de501b4dd7957">QwtPlotCurve::setCurveFitter</a>(<a class="code" href="class_qwt_curve_fitter.html">QwtCurveFitter</a> *curveFitter)
747
<a name="l01033"></a>01033 {
748
<a name="l01034"></a>01034 <span class="keyword">delete</span> d_data->curveFitter;
749
<a name="l01035"></a>01035 d_data->curveFitter = <a class="code" href="class_qwt_plot_curve.html#af299522e4ad972996c781aacc940d31">curveFitter</a>;
750
<a name="l01036"></a>01036
751
<a name="l01037"></a>01037 <a class="code" href="class_qwt_plot_item.html#d956fdbce5b0721abccce6d09fe4d5ce">itemChanged</a>();
752
<a name="l01038"></a>01038 }
753
<a name="l01039"></a>01039
754
<a name="l01040"></a><a class="code" href="class_qwt_plot_curve.html#af299522e4ad972996c781aacc940d31">01040</a> <a class="code" href="class_qwt_curve_fitter.html">QwtCurveFitter</a> *<a class="code" href="class_qwt_plot_curve.html#af299522e4ad972996c781aacc940d31">QwtPlotCurve::curveFitter</a>()<span class="keyword"> const</span>
755
<a name="l01041"></a>01041 <span class="keyword"></span>{
756
<a name="l01042"></a>01042 <span class="keywordflow">return</span> d_data->curveFitter;
757
<a name="l01043"></a>01043 }
758
<a name="l01044"></a>01044
759
<a name="l01057"></a><a class="code" href="class_qwt_plot_curve.html#4003f0a4badb1381c3c00f83dde33daf">01057</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#4003f0a4badb1381c3c00f83dde33daf">QwtPlotCurve::fillCurve</a>(QPainter *painter,
760
<a name="l01058"></a>01058 <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &xMap, <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &yMap,
761
<a name="l01059"></a>01059 QwtPolygon &pa)<span class="keyword"> const</span>
762
<a name="l01060"></a>01060 <span class="keyword"></span>{
763
<a name="l01061"></a>01061 <span class="keywordflow">if</span> ( d_data->brush.style() == Qt::NoBrush )
764
<a name="l01062"></a>01062 <span class="keywordflow">return</span>;
765
<a name="l01063"></a>01063
766
<a name="l01064"></a>01064 <a class="code" href="class_qwt_plot_curve.html#1ba57cbd293566b068669c876ce1263d">closePolyline</a>(xMap, yMap, pa);
767
<a name="l01065"></a>01065 <span class="keywordflow">if</span> ( pa.count() <= 2 ) <span class="comment">// a line can't be filled</span>
768
<a name="l01066"></a>01066 <span class="keywordflow">return</span>;
769
<a name="l01067"></a>01067
770
<a name="l01068"></a>01068 QBrush b = d_data->brush;
771
<a name="l01069"></a>01069 <span class="keywordflow">if</span> ( !b.color().isValid() )
772
<a name="l01070"></a>01070 b.setColor(d_data->pen.color());
773
<a name="l01071"></a>01071
774
<a name="l01072"></a>01072 painter->save();
775
<a name="l01073"></a>01073
776
<a name="l01074"></a>01074 painter->setPen(QPen(Qt::NoPen));
777
<a name="l01075"></a>01075 painter->setBrush(b);
778
<a name="l01076"></a>01076
779
<a name="l01077"></a>01077 <a class="code" href="class_qwt_painter.html#ea6a68bdfab18525b39f18413fc41950">QwtPainter::drawPolygon</a>(painter, pa);
780
<a name="l01078"></a>01078
781
<a name="l01079"></a>01079 painter->restore();
782
<a name="l01080"></a>01080 }
783
<a name="l01081"></a>01081
784
<a name="l01091"></a><a class="code" href="class_qwt_plot_curve.html#1ba57cbd293566b068669c876ce1263d">01091</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#1ba57cbd293566b068669c876ce1263d">QwtPlotCurve::closePolyline</a>(
785
<a name="l01092"></a>01092 <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &xMap, <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &yMap,
786
<a name="l01093"></a>01093 QwtPolygon &pa)<span class="keyword"> const</span>
787
<a name="l01094"></a>01094 <span class="keyword"></span>{
788
<a name="l01095"></a>01095 <span class="keyword">const</span> <span class="keywordtype">int</span> sz = pa.size();
789
<a name="l01096"></a>01096 <span class="keywordflow">if</span> ( sz < 2 )
790
<a name="l01097"></a>01097 <span class="keywordflow">return</span>;
791
<a name="l01098"></a>01098
792
<a name="l01099"></a>01099 pa.resize(sz + 2);
793
<a name="l01100"></a>01100
794
<a name="l01101"></a>01101 <span class="keywordflow">if</span> ( d_data->attributes & QwtPlotCurve::Xfy )
795
<a name="l01102"></a>01102 {
796
<a name="l01103"></a>01103 pa.setPoint(sz,
797
<a name="l01104"></a>01104 xMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(d_data->reference), pa.point(sz - 1).y());
798
<a name="l01105"></a>01105 pa.setPoint(sz + 1,
799
<a name="l01106"></a>01106 xMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(d_data->reference), pa.point(0).y());
800
<a name="l01107"></a>01107 }
801
<a name="l01108"></a>01108 <span class="keywordflow">else</span>
802
<a name="l01109"></a>01109 {
803
<a name="l01110"></a>01110 pa.setPoint(sz,
804
<a name="l01111"></a>01111 pa.point(sz - 1).x(), yMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(d_data->reference));
805
<a name="l01112"></a>01112 pa.setPoint(pa.size() - 1,
806
<a name="l01113"></a>01113 pa.point(0).x(), yMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(d_data->reference));
807
<a name="l01114"></a>01114 }
808
<a name="l01115"></a>01115 }
809
<a name="l01116"></a>01116
810
<a name="l01128"></a><a class="code" href="class_qwt_plot_curve.html#b16f5a4329291305c267beab1a6d2dfe">01128</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#b16f5a4329291305c267beab1a6d2dfe">QwtPlotCurve::drawSymbols</a>(QPainter *painter, <span class="keyword">const</span> <a class="code" href="class_qwt_symbol.html">QwtSymbol</a> &symbol,
811
<a name="l01129"></a>01129 <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &xMap, <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &yMap,
812
<a name="l01130"></a>01130 <span class="keywordtype">int</span> from, <span class="keywordtype">int</span> to)<span class="keyword"> const</span>
813
<a name="l01131"></a>01131 <span class="keyword"></span>{
814
<a name="l01132"></a>01132 painter->setBrush(<a class="code" href="class_qwt_plot_curve.html#4278ed4f767e394b6f92ce4e5d25231a">symbol</a>.<a class="code" href="class_qwt_symbol.html#a23606467898677666953e3ea4478588">brush</a>());
815
<a name="l01133"></a>01133 painter->setPen(<a class="code" href="class_qwt_plot_curve.html#4278ed4f767e394b6f92ce4e5d25231a">symbol</a>.<a class="code" href="class_qwt_symbol.html#c4eb82409994757742577a80e9915e79">pen</a>());
816
<a name="l01134"></a>01134
817
<a name="l01135"></a>01135 QRect rect;
818
<a name="l01136"></a>01136 rect.setSize(<a class="code" href="class_qwt_painter.html#3de95bfc83c9beee537404b41749bad5">QwtPainter::metricsMap</a>().screenToLayout(<a class="code" href="class_qwt_plot_curve.html#4278ed4f767e394b6f92ce4e5d25231a">symbol</a>.<a class="code" href="class_qwt_symbol.html#14be5234a29cbdde1e9b0ae92abe76ea">size</a>()));
819
<a name="l01137"></a>01137
820
<a name="l01138"></a>01138 <span class="keywordflow">if</span> ( to > from && d_data->paintAttributes & PaintFiltered )
821
<a name="l01139"></a>01139 {
822
<a name="l01140"></a>01140 <span class="keyword">const</span> QRect window = painter->window();
823
<a name="l01141"></a>01141 <span class="keywordflow">if</span> ( window.isEmpty() )
824
<a name="l01142"></a>01142 <span class="keywordflow">return</span>;
825
<a name="l01143"></a>01143
826
<a name="l01144"></a>01144 PrivateData::PixelMatrix pixelMatrix(window);
827
<a name="l01145"></a>01145
828
<a name="l01146"></a>01146 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = from; i <= to; i++)
829
<a name="l01147"></a>01147 {
830
<a name="l01148"></a>01148 <span class="keyword">const</span> QPoint pi( xMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(<a class="code" href="class_qwt_plot_curve.html#312b1fe8635430c293ee8fdc9fcfd774">x</a>(i)),
831
<a name="l01149"></a>01149 yMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(<a class="code" href="class_qwt_plot_curve.html#db2885f90bfe2ce1f83929a20dffc38e">y</a>(i)) );
832
<a name="l01150"></a>01150
833
<a name="l01151"></a>01151 <span class="keywordflow">if</span> ( pixelMatrix.testPixel(pi) )
834
<a name="l01152"></a>01152 {
835
<a name="l01153"></a>01153 rect.moveCenter(pi);
836
<a name="l01154"></a>01154 <a class="code" href="class_qwt_plot_curve.html#4278ed4f767e394b6f92ce4e5d25231a">symbol</a>.<a class="code" href="class_qwt_symbol.html#5a88bcd704acadbda4ae9dea82b22c57">draw</a>(painter, rect);
837
<a name="l01155"></a>01155 }
838
<a name="l01156"></a>01156 }
839
<a name="l01157"></a>01157 }
840
<a name="l01158"></a>01158 <span class="keywordflow">else</span>
841
<a name="l01159"></a>01159 {
842
<a name="l01160"></a>01160 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = from; i <= to; i++)
843
<a name="l01161"></a>01161 {
844
<a name="l01162"></a>01162 <span class="keyword">const</span> <span class="keywordtype">int</span> xi = xMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(x(i));
845
<a name="l01163"></a>01163 <span class="keyword">const</span> <span class="keywordtype">int</span> yi = yMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(y(i));
846
<a name="l01164"></a>01164
847
<a name="l01165"></a>01165 rect.moveCenter(QPoint(xi, yi));
848
<a name="l01166"></a>01166 symbol.draw(painter, rect);
849
<a name="l01167"></a>01167 }
850
<a name="l01168"></a>01168 }
851
<a name="l01169"></a>01169 }
852
<a name="l01170"></a>01170
853
<a name="l01184"></a><a class="code" href="class_qwt_plot_curve.html#2d60cc9c35527480ad3a7b2f668d05fc">01184</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#2d60cc9c35527480ad3a7b2f668d05fc">QwtPlotCurve::setBaseline</a>(<span class="keywordtype">double</span> reference)
854
<a name="l01185"></a>01185 {
855
<a name="l01186"></a>01186 <span class="keywordflow">if</span> ( d_data->reference != reference )
856
<a name="l01187"></a>01187 {
857
<a name="l01188"></a>01188 d_data->reference = reference;
858
<a name="l01189"></a>01189 <a class="code" href="class_qwt_plot_item.html#d956fdbce5b0721abccce6d09fe4d5ce">itemChanged</a>();
859
<a name="l01190"></a>01190 }
860
<a name="l01191"></a>01191 }
861
<a name="l01192"></a>01192
862
<a name="l01197"></a><a class="code" href="class_qwt_plot_curve.html#93e390b172c5fa9ffd534aeb2d572c0e">01197</a> <span class="keywordtype">double</span> <a class="code" href="class_qwt_plot_curve.html#93e390b172c5fa9ffd534aeb2d572c0e">QwtPlotCurve::baseline</a>()<span class="keyword"> const </span>
863
<a name="l01198"></a>01198 <span class="keyword"></span>{
864
<a name="l01199"></a>01199 <span class="keywordflow">return</span> d_data->reference;
865
<a name="l01200"></a>01200 }
866
<a name="l01201"></a>01201
867
<a name="l01206"></a><a class="code" href="class_qwt_plot_curve.html#261170c51a8e6853f333c76c501992b7">01206</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot_curve.html#261170c51a8e6853f333c76c501992b7">QwtPlotCurve::dataSize</a>()<span class="keyword"> const</span>
868
<a name="l01207"></a>01207 <span class="keyword"></span>{
869
<a name="l01208"></a>01208 <span class="keywordflow">return</span> d_xy-><a class="code" href="class_qwt_data.html#6028c06e7e72de98fb7a8a3ec6acdf47">size</a>();
870
<a name="l01209"></a>01209 }
871
<a name="l01210"></a>01210
872
<a name="l01211"></a><a class="code" href="class_qwt_plot_curve.html#47620cb8ca3940f7007f8fb990d614f6">01211</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot_curve.html#47620cb8ca3940f7007f8fb990d614f6">QwtPlotCurve::closestPoint</a>(<span class="keyword">const</span> QPoint &pos, <span class="keywordtype">double</span> *dist)<span class="keyword"> const</span>
873
<a name="l01212"></a>01212 <span class="keyword"></span>{
874
<a name="l01213"></a>01213 <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_plot_item.html#4c99653a14a49ad94d466168d06e97b9">plot</a>() == NULL || <a class="code" href="class_qwt_plot_curve.html#261170c51a8e6853f333c76c501992b7">dataSize</a>() <= 0 )
875
<a name="l01214"></a>01214 <span class="keywordflow">return</span> -1;
876
<a name="l01215"></a>01215
877
<a name="l01216"></a>01216 <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> xMap = <a class="code" href="class_qwt_plot_item.html#4c99653a14a49ad94d466168d06e97b9">plot</a>()-><a class="code" href="class_qwt_plot.html#ff5efd21f11ec91fb8f791799cb4db2f">canvasMap</a>(<a class="code" href="class_qwt_plot_item.html#7af360bf6d5a5b6257ce6b0dd99b7525">xAxis</a>());
878
<a name="l01217"></a>01217 <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> yMap = <a class="code" href="class_qwt_plot_item.html#4c99653a14a49ad94d466168d06e97b9">plot</a>()-><a class="code" href="class_qwt_plot.html#ff5efd21f11ec91fb8f791799cb4db2f">canvasMap</a>(<a class="code" href="class_qwt_plot_item.html#c7714ffa278a10e0cf45972e487b63ff">yAxis</a>());
879
<a name="l01218"></a>01218
880
<a name="l01219"></a>01219 <span class="keywordtype">int</span> index = -1;
881
<a name="l01220"></a>01220 <span class="keywordtype">double</span> dmin = 1.0e10;
882
<a name="l01221"></a>01221
883
<a name="l01222"></a>01222 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i < <a class="code" href="class_qwt_plot_curve.html#261170c51a8e6853f333c76c501992b7">dataSize</a>(); i++)
884
<a name="l01223"></a>01223 {
885
<a name="l01224"></a>01224 <span class="keyword">const</span> <span class="keywordtype">double</span> cx = xMap.<a class="code" href="class_qwt_scale_map.html#053cad00dd463f45c7e1591c9f2d8296">xTransform</a>(<a class="code" href="class_qwt_plot_curve.html#312b1fe8635430c293ee8fdc9fcfd774">x</a>(i)) - pos.x();
886
<a name="l01225"></a>01225 <span class="keyword">const</span> <span class="keywordtype">double</span> cy = yMap.<a class="code" href="class_qwt_scale_map.html#053cad00dd463f45c7e1591c9f2d8296">xTransform</a>(<a class="code" href="class_qwt_plot_curve.html#db2885f90bfe2ce1f83929a20dffc38e">y</a>(i)) - pos.y();
887
<a name="l01226"></a>01226
888
<a name="l01227"></a>01227 <span class="keyword">const</span> <span class="keywordtype">double</span> f = qwtSqr(cx) + qwtSqr(cy);
889
<a name="l01228"></a>01228 <span class="keywordflow">if</span> (f < dmin)
890
<a name="l01229"></a>01229 {
891
<a name="l01230"></a>01230 index = i;
892
<a name="l01231"></a>01231 dmin = f;
893
<a name="l01232"></a>01232 }
894
<a name="l01233"></a>01233 }
895
<a name="l01234"></a>01234 <span class="keywordflow">if</span> ( dist )
896
<a name="l01235"></a>01235 *dist = sqrt(dmin);
897
<a name="l01236"></a>01236
898
<a name="l01237"></a>01237 <span class="keywordflow">return</span> index;
899
<a name="l01238"></a>01238 }
900
<a name="l01239"></a>01239
901
<a name="l01240"></a><a class="code" href="class_qwt_plot_curve.html#edbca95048e4c7b42cd0bf486ec36b4d">01240</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_curve.html#edbca95048e4c7b42cd0bf486ec36b4d">QwtPlotCurve::updateLegend</a>(<a class="code" href="class_qwt_legend.html">QwtLegend</a> *legend)<span class="keyword"> const</span>
902
<a name="l01241"></a>01241 <span class="keyword"></span>{
903
<a name="l01242"></a>01242 <span class="keywordflow">if</span> ( !legend )
904
<a name="l01243"></a>01243 <span class="keywordflow">return</span>;
905
<a name="l01244"></a>01244
906
<a name="l01245"></a>01245 <a class="code" href="class_qwt_plot_item.html#193770cd20609a368c5130de59cb782e">QwtPlotItem::updateLegend</a>(legend);
907
<a name="l01246"></a>01246
908
<a name="l01247"></a>01247 QWidget *widget = legend-><a class="code" href="class_qwt_legend.html#ae136e8199d5a3caf86a7767c1de186c">find</a>(<span class="keyword">this</span>);
909
<a name="l01248"></a>01248 <span class="keywordflow">if</span> ( !widget || !widget->inherits(<span class="stringliteral">"QwtLegendItem"</span>) )
910
<a name="l01249"></a>01249 <span class="keywordflow">return</span>;
911
<a name="l01250"></a>01250
912
<a name="l01251"></a>01251 <a class="code" href="class_qwt_legend_item.html">QwtLegendItem</a> *<a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a> = (<a class="code" href="class_qwt_legend_item.html">QwtLegendItem</a> *)widget;
913
<a name="l01252"></a>01252
914
<a name="l01253"></a>01253 <span class="preprocessor">#if QT_VERSION < 0x040000</span>
915
<a name="l01254"></a>01254 <span class="preprocessor"></span> <span class="keyword">const</span> <span class="keywordtype">bool</span> doUpdate = <a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a>->isUpdatesEnabled();
916
<a name="l01255"></a>01255 <span class="preprocessor">#else</span>
917
<a name="l01256"></a>01256 <span class="preprocessor"></span> <span class="keyword">const</span> <span class="keywordtype">bool</span> doUpdate = <a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a>->updatesEnabled();
918
<a name="l01257"></a>01257 <span class="preprocessor">#endif</span>
919
<a name="l01258"></a>01258 <span class="preprocessor"></span> <a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a>->setUpdatesEnabled(<span class="keyword">false</span>);
920
<a name="l01259"></a>01259
921
<a name="l01260"></a>01260 <span class="keyword">const</span> <span class="keywordtype">int</span> policy = legend-><a class="code" href="class_qwt_legend.html#a74ccc6083345a1517ffbb86356f7ba0">displayPolicy</a>();
922
<a name="l01261"></a>01261
923
<a name="l01262"></a>01262 <span class="keywordflow">if</span> (policy == QwtLegend::FixedIdentifier)
924
<a name="l01263"></a>01263 {
925
<a name="l01264"></a>01264 <span class="keywordtype">int</span> mode = legend-><a class="code" href="class_qwt_legend.html#a0d1126ccd9f65b0926ce7c802f74e6a">identifierMode</a>();
926
<a name="l01265"></a>01265
927
<a name="l01266"></a>01266 <span class="keywordflow">if</span> (mode & QwtLegendItem::ShowLine)
928
<a name="l01267"></a>01267 <a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a>->setCurvePen(<a class="code" href="class_qwt_plot_curve.html#778aafd1385ce833821751d0a8635cef">pen</a>());
929
<a name="l01268"></a>01268
930
<a name="l01269"></a>01269 <span class="keywordflow">if</span> (mode & QwtLegendItem::ShowSymbol)
931
<a name="l01270"></a>01270 <a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a>->setSymbol(<a class="code" href="class_qwt_plot_curve.html#4278ed4f767e394b6f92ce4e5d25231a">symbol</a>());
932
<a name="l01271"></a>01271
933
<a name="l01272"></a>01272 <span class="keywordflow">if</span> (mode & QwtLegendItem::ShowText)
934
<a name="l01273"></a>01273 <a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a>->setText(<a class="code" href="class_qwt_plot_item.html#3859d011b670b5f89e45d1ccef9206f7">title</a>());
935
<a name="l01274"></a>01274 <span class="keywordflow">else</span>
936
<a name="l01275"></a>01275 <a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a>->setText(<a class="code" href="class_qwt_text.html">QwtText</a>());
937
<a name="l01276"></a>01276
938
<a name="l01277"></a>01277 <a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a>->setIdentifierMode(mode);
939
<a name="l01278"></a>01278 }
940
<a name="l01279"></a>01279 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (policy == QwtLegend::AutoIdentifier)
941
<a name="l01280"></a>01280 {
942
<a name="l01281"></a>01281 <span class="keywordtype">int</span> mode = 0;
943
<a name="l01282"></a>01282
944
<a name="l01283"></a>01283 <span class="keywordflow">if</span> (QwtPlotCurve::NoCurve != <a class="code" href="class_qwt_plot_curve.html#2df43bdea2a17118c9114d6fa774e598">style</a>())
945
<a name="l01284"></a>01284 {
946
<a name="l01285"></a>01285 <a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a>->setCurvePen(<a class="code" href="class_qwt_plot_curve.html#778aafd1385ce833821751d0a8635cef">pen</a>());
947
<a name="l01286"></a>01286 mode |= QwtLegendItem::ShowLine;
948
<a name="l01287"></a>01287 }
949
<a name="l01288"></a>01288 <span class="keywordflow">if</span> (QwtSymbol::NoSymbol != <a class="code" href="class_qwt_plot_curve.html#4278ed4f767e394b6f92ce4e5d25231a">symbol</a>().<a class="code" href="class_qwt_plot_curve.html#2df43bdea2a17118c9114d6fa774e598">style</a>())
950
<a name="l01289"></a>01289 {
951
<a name="l01290"></a>01290 <a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a>->setSymbol(<a class="code" href="class_qwt_plot_curve.html#4278ed4f767e394b6f92ce4e5d25231a">symbol</a>());
952
<a name="l01291"></a>01291 mode |= QwtLegendItem::ShowSymbol;
953
<a name="l01292"></a>01292 }
954
<a name="l01293"></a>01293 <span class="keywordflow">if</span> ( !<a class="code" href="class_qwt_plot_item.html#3859d011b670b5f89e45d1ccef9206f7">title</a>().isEmpty() )
955
<a name="l01294"></a>01294 {
956
<a name="l01295"></a>01295 <a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a>->setText(<a class="code" href="class_qwt_plot_item.html#3859d011b670b5f89e45d1ccef9206f7">title</a>());
957
<a name="l01296"></a>01296 mode |= QwtLegendItem::ShowText;
958
<a name="l01297"></a>01297 }
959
<a name="l01298"></a>01298 <span class="keywordflow">else</span>
960
<a name="l01299"></a>01299 {
961
<a name="l01300"></a>01300 <a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a>->setText(<a class="code" href="class_qwt_text.html">QwtText</a>());
962
<a name="l01301"></a>01301 }
963
<a name="l01302"></a>01302 <a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a>->setIdentifierMode(mode);
964
<a name="l01303"></a>01303 }
965
<a name="l01304"></a>01304
966
<a name="l01305"></a>01305 <a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a>->setUpdatesEnabled(doUpdate);
967
<a name="l01306"></a>01306 <a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a>->update();
968
<a name="l01307"></a>01307 }
969
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Mon Feb 26 21:22:37 2007 for Qwt User's Guide by
970
<a href="http://www.doxygen.org/index.html">
971
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>