File: qwt__plot__curve_8cpp-source.html

package info (click to toggle)
libqwt 4.2.0-4.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 9,832 kB
  • ctags: 5,512
  • sloc: cpp: 22,973; ansic: 244; makefile: 66
file content (528 lines) | stat: -rw-r--r-- 37,251 bytes parent folder | download | duplicates (5)
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
<!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>Qwt User&apos;s Guide: qwt_plot_curve.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.8 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
<h1>qwt_plot_curve.cpp</h1><pre class="fragment"><div>00001 <span class="comment">/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************</span>
00002 <span class="comment"> * Qwt Widget Library</span>
00003 <span class="comment"> * Copyright (C) 1997   Josef Wilgen</span>
00004 <span class="comment"> * Copyright (C) 2002   Uwe Rathmann</span>
00005 <span class="comment"> * </span>
00006 <span class="comment"> * This library is free software; you can redistribute it and/or</span>
00007 <span class="comment"> * modify it under the terms of the Qwt License, Version 1.0</span>
00008 <span class="comment"> *****************************************************************************/</span>
00009 
00010 <span class="preprocessor">#include "qwt_plot.h"</span>
00011 <span class="preprocessor">#include "qwt_plot_dict.h"</span>
00012 <span class="preprocessor">#include "<a class="code" href="qwt__math_8h.html">qwt_math.h</a>"</span>
00013 <span class="preprocessor">#include "qwt_legend.h"</span>
00014 
<a name="l00016"></a><a class="code" href="class_qwt_plot.html#a37">00016</a> QwtPlotCurveIterator <a class="code" href="class_qwt_plot.html#a37">QwtPlot::curveIterator</a>()<span class="keyword"> const</span>
00017 <span class="keyword"></span>{
00018     <span class="keywordflow">return</span> QwtPlotCurveIterator(*d_curves);
00019 }
00020 
<a name="l00030"></a><a class="code" href="class_qwt_plot.html#a47">00030</a> <span class="keywordtype">long</span> <a class="code" href="class_qwt_plot.html#a47">QwtPlot::closestCurve</a>(<span class="keywordtype">int</span> xpos, <span class="keywordtype">int</span> ypos, <span class="keywordtype">int</span> &amp;dist)<span class="keyword"> const</span>
00031 <span class="keyword"></span>{
00032     <span class="keywordtype">double</span> x,y;
00033     <span class="keywordtype">int</span> index;
00034     <span class="keywordflow">return</span> <a class="code" href="class_qwt_plot.html#a47">closestCurve</a>(xpos, ypos, dist, x,y, index);
00035 }
00036 
<a name="l00050"></a><a class="code" href="class_qwt_plot.html#a48">00050</a> <span class="keywordtype">long</span> <a class="code" href="class_qwt_plot.html#a47">QwtPlot::closestCurve</a>(<span class="keywordtype">int</span> xpos, <span class="keywordtype">int</span> ypos, <span class="keywordtype">int</span> &amp;dist, <span class="keywordtype">double</span> &amp;xval,
00051                            <span class="keywordtype">double</span> &amp;yval, <span class="keywordtype">int</span> &amp;index)<span class="keyword"> const</span>
00052 <span class="keyword"></span>{
00053     <a class="code" href="class_qwt_di_map.html">QwtDiMap</a> map[axisCnt];
00054     <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot.html#a109">axis</a> = 0; axis &lt; axisCnt; axis++ )
00055         map[axis] = <a class="code" href="class_qwt_plot.html#a39">canvasMap</a>(axis);
00056 
00057     <span class="keywordtype">long</span> rv = 0;
00058     <span class="keywordtype">double</span> dmin = 1.0e10;
00059 
00060     QwtPlotCurveIterator itc = <a class="code" href="class_qwt_plot.html#a37">curveIterator</a>();
00061     <span class="keywordflow">for</span> (<a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = itc.toFirst(); c != 0; c = ++itc )
00062     {
00063         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;c-&gt;<a class="code" href="class_qwt_curve.html#a9">dataSize</a>(); i++)
00064         {
00065             <span class="keywordtype">double</span> cx = map[c-&gt;<a class="code" href="class_qwt_plot_mapped_item.html#a3">xAxis</a>()].<a class="code" href="class_qwt_di_map.html#a10">xTransform</a>(c-&gt;<a class="code" href="class_qwt_curve.html#a10">x</a>(i)) - double(xpos);
00066             <span class="keywordtype">double</span> cy = map[c-&gt;<a class="code" href="class_qwt_plot_mapped_item.html#a5">yAxis</a>()].xTransform(c-&gt;<a class="code" href="class_qwt_curve.html#a11">y</a>(i)) - double(ypos);
00067 
00068             <span class="keywordtype">double</span> f = <a class="code" href="qwt__math_8h.html#a31">qwtSqr</a>(cx) + <a class="code" href="qwt__math_8h.html#a31">qwtSqr</a>(cy);
00069             <span class="keywordflow">if</span> (f &lt; dmin)
00070             {
00071                 dmin = f;
00072                 rv = itc.currentKey();
00073                 xval = c-&gt;<a class="code" href="class_qwt_curve.html#a10">x</a>(i);
00074                 yval = c-&gt;<a class="code" href="class_qwt_curve.html#a11">y</a>(i);
00075                 index = i;
00076             }
00077         }
00078     }
00079 
00080     dist = int(sqrt(dmin));
00081     <span class="keywordflow">return</span> rv;
00082 }
00083 
00084 
00085 
<a name="l00091"></a><a class="code" href="class_qwt_plot.html#a65">00091</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot.html#a65">QwtPlot::curveStyle</a>(<span class="keywordtype">long</span> key)<span class="keyword"> const</span>
00092 <span class="keyword"></span>{
00093     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00094     <span class="keywordflow">return</span> c ? c-&gt;<a class="code" href="class_qwt_curve.html#a28">style</a>() : 0;
00095 }
00096 
<a name="l00103"></a><a class="code" href="class_qwt_plot.html#a67">00103</a> <a class="code" href="class_qwt_symbol.html">QwtSymbol</a> <a class="code" href="class_qwt_plot.html#a67">QwtPlot::curveSymbol</a>(<span class="keywordtype">long</span> key)<span class="keyword"> const</span>
00104 <span class="keyword"></span>{
00105     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00106     <span class="keywordflow">return</span> c ? c-&gt;<a class="code" href="class_qwt_curve.html#a30">symbol</a>() : <a class="code" href="class_qwt_symbol.html">QwtSymbol</a>();
00107 }
00108 
<a name="l00113"></a><a class="code" href="class_qwt_plot.html#a59">00113</a> QPen <a class="code" href="class_qwt_plot.html#a59">QwtPlot::curvePen</a>(<span class="keywordtype">long</span> key)<span class="keyword"> const</span>
00114 <span class="keyword"></span>{
00115     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00116     <span class="keywordflow">return</span> c ? c-&gt;<a class="code" href="class_qwt_curve.html#a22">pen</a>() : QPen();
00117 }
00118 
<a name="l00124"></a><a class="code" href="class_qwt_plot.html#a61">00124</a> QBrush <a class="code" href="class_qwt_plot.html#a61">QwtPlot::curveBrush</a>(<span class="keywordtype">long</span> key)<span class="keyword"> const</span>
00125 <span class="keyword"></span>{
00126     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00127     <span class="keywordflow">return</span> c ? c-&gt;<a class="code" href="class_qwt_curve.html#a24">brush</a>() : QBrush();
00128 }
<a name="l00133"></a><a class="code" href="class_qwt_plot.html#a57">00133</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot.html#a57">QwtPlot::curveOptions</a>(<span class="keywordtype">long</span> key)<span class="keyword"> const</span>
00134 <span class="keyword"></span>{
00135     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00136     <span class="keywordflow">return</span> c ? c-&gt;<a class="code" href="class_qwt_curve.html#a18">options</a>() : 0;
00137 }
00138 
<a name="l00143"></a><a class="code" href="class_qwt_plot.html#a63">00143</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot.html#a63">QwtPlot::curveSplineSize</a>(<span class="keywordtype">long</span> key)<span class="keyword"> const</span>
00144 <span class="keyword"></span>{
00145     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00146     <span class="keywordflow">return</span> c ? c-&gt;<a class="code" href="class_qwt_curve.html#a32">splineSize</a>() : 0;
00147 }
00148 
<a name="l00153"></a><a class="code" href="class_qwt_plot.html#a69">00153</a> QString <a class="code" href="class_qwt_plot.html#a69">QwtPlot::curveTitle</a>(<span class="keywordtype">long</span> key)<span class="keyword"> const</span>
00154 <span class="keyword"></span>{
00155     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00156     <span class="keywordflow">return</span> c ? c-&gt;<a class="code" href="class_qwt_curve.html#a20">title</a>() : QString::null;
00157 }
00158 
<a name="l00162"></a><a class="code" href="class_qwt_plot.html#a46">00162</a> QwtArray&lt;long&gt; <a class="code" href="class_qwt_plot.html#a46">QwtPlot::curveKeys</a>()<span class="keyword"> const</span>
00163 <span class="keyword"></span>{
00164     QwtArray&lt;long&gt; keys(d_curves-&gt;count());
00165 
00166     <span class="keywordtype">int</span> i = 0;
00167 
00168     QwtPlotCurveIterator itc = <a class="code" href="class_qwt_plot.html#a37">curveIterator</a>();
00169     <span class="keywordflow">for</span> (<span class="keyword">const</span> <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = itc.toFirst(); c != 0; c = ++itc, i++ )
00170         keys[i] = itc.currentKey();
00171 
00172     <span class="keywordflow">return</span> keys;
00173 }
00174 
<a name="l00180"></a><a class="code" href="class_qwt_plot.html#a71">00180</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot.html#a71">QwtPlot::curveXAxis</a>(<span class="keywordtype">long</span> key)<span class="keyword"> const</span>
00181 <span class="keyword"></span>{
00182     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00183     <span class="keywordflow">return</span> c ? c-&gt;<a class="code" href="class_qwt_plot_mapped_item.html#a3">xAxis</a>() : -1;
00184 }
00185 
00186 
<a name="l00192"></a><a class="code" href="class_qwt_plot.html#a73">00192</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot.html#a73">QwtPlot::curveYAxis</a>(<span class="keywordtype">long</span> key)<span class="keyword"> const</span>
00193 <span class="keyword"></span>{
00194     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00195     <span class="keywordflow">return</span> c ? c-&gt;<a class="code" href="class_qwt_plot_mapped_item.html#a5">yAxis</a>() : -1;
00196 }
00197 
00198 
00203 <span class="keywordtype">long</span> QwtPlot::newCurveKey()
00204 {
00205     <span class="keywordtype">long</span> newkey = d_curves-&gt;count() + 1;
00206 
00207     <span class="keywordflow">if</span> (newkey &gt; 1)                     <span class="comment">// size &gt; 0: check if key exists</span>
00208     {
00209         <span class="keywordflow">if</span> (d_curves-&gt;find(newkey))     <span class="comment">// key size+1 exists =&gt; there must be a</span>
00210                                         <span class="comment">// free key &lt;= size</span>
00211         {
00212             <span class="comment">// find the first available key &lt;= size</span>
00213             newkey = 1;
00214             <span class="keywordflow">while</span> (newkey &lt;= long(d_curves-&gt;count()))
00215             {
00216                 <span class="keywordflow">if</span> (d_curves-&gt;find(newkey))
00217                    newkey++;
00218                 <span class="keywordflow">else</span>
00219                    <span class="keywordflow">break</span>;
00220             }
00221 
00222             <span class="comment">// This can't happen. Just paranoia.</span>
00223             <span class="keywordflow">if</span> (newkey &gt; long(d_curves-&gt;count()))
00224             {
00225                 <span class="keywordflow">while</span> (!d_curves-&gt;find(newkey))
00226                 {
00227                     newkey++;
00228                     <span class="keywordflow">if</span> (newkey &gt; 10000) <span class="comment">// prevent infinite loop</span>
00229                     {
00230                         newkey = 0;
00231                         <span class="keywordflow">break</span>;
00232                     }
00233                 }
00234             }
00235         }
00236     }
00237     <span class="keywordflow">return</span> newkey;
00238 }
00239 
<a name="l00247"></a><a class="code" href="class_qwt_plot.html#a42">00247</a> <span class="keywordtype">long</span> <a class="code" href="class_qwt_plot.html#a42">QwtPlot::insertCurve</a>(<a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *curve)
00248 {
00249     <span class="keywordflow">if</span> (curve == 0)
00250         <span class="keywordflow">return</span> 0;
00251 
00252     <span class="keywordtype">long</span> key = newCurveKey();
00253     <span class="keywordflow">if</span> (key == 0)
00254         <span class="keywordflow">return</span> 0;
00255 
00256     curve-&gt;<a class="code" href="class_qwt_plot_item.html#a2">reparent</a>(<span class="keyword">this</span>);
00257 
00258     d_curves-&gt;insert(key, curve);
00259     <span class="keywordflow">if</span> (d_autoLegend)
00260     {
00261         <a class="code" href="class_qwt_plot.html#b8">insertLegendItem</a>(key);
00262         <a class="code" href="class_qwt_plot.html#b6">updateLayout</a>();
00263     }
00264 
00265     <span class="keywordflow">return</span> key;
00266 }
00267 
<a name="l00276"></a><a class="code" href="class_qwt_plot.html#a43">00276</a> <span class="keywordtype">long</span> <a class="code" href="class_qwt_plot.html#a42">QwtPlot::insertCurve</a>(<span class="keyword">const</span> QString &amp;title, <span class="keywordtype">int</span> xAxis, <span class="keywordtype">int</span> yAxis)
00277 {
00278     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *<a class="code" href="class_qwt_plot.html#a44">curve</a> = <span class="keyword">new</span> <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a>(<span class="keyword">this</span>);
00279     <span class="keywordflow">if</span> (!curve)
00280         <span class="keywordflow">return</span> 0;
00281 
00282     curve-&gt;<a class="code" href="class_qwt_plot_mapped_item.html#a1">setAxis</a>(xAxis, yAxis);
00283     curve-&gt;<a class="code" href="class_qwt_curve.html#a19">setTitle</a>(title);
00284 
00285     <span class="keywordtype">long</span> key = <a class="code" href="class_qwt_plot.html#a42">insertCurve</a>(curve);
00286     <span class="keywordflow">if</span> ( key == 0 )
00287         <span class="keyword">delete</span> curve;
00288 
00289     <span class="keywordflow">return</span> key;
00290 }
00291 
<a name="l00297"></a><a class="code" href="class_qwt_plot.html#a44">00297</a> <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *<a class="code" href="class_qwt_plot.html#a44">QwtPlot::curve</a>(<span class="keywordtype">long</span> key)
00298 {
00299     <span class="keywordflow">return</span> d_curves-&gt;find(key);
00300 }
00301 
<a name="l00307"></a><a class="code" href="class_qwt_plot.html#a45">00307</a> <span class="keyword">const</span> <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *<a class="code" href="class_qwt_plot.html#a44">QwtPlot::curve</a>(<span class="keywordtype">long</span> key)<span class="keyword"> const</span>
00308 <span class="keyword"></span>{
00309     <span class="keywordflow">return</span> d_curves-&gt;find(key);
00310 }
00311 
00312 
<a name="l00317"></a><a class="code" href="class_qwt_plot.html#i1">00317</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot.html#i1">QwtPlot::removeCurve</a>(<span class="keywordtype">long</span> key)
00318 {
00319     <span class="keywordtype">bool</span> ok = d_curves-&gt;remove(key);
00320     <span class="keywordflow">if</span> ( !ok )
00321         <span class="keywordflow">return</span> FALSE;
00322 
00323     QWidget *item = d_legend-&gt;<a class="code" href="class_qwt_legend.html#a9">findItem</a>(key);
00324     <span class="keywordflow">if</span> ( item )
00325     {
00326         <span class="keyword">delete</span> item;
00327         <a class="code" href="class_qwt_plot.html#b6">updateLayout</a>();
00328     }
00329     
00330     <a class="code" href="class_qwt_plot.html#b0">autoRefresh</a>();
00331     <span class="keywordflow">return</span> TRUE;
00332 }
00333 
<a name="l00340"></a><a class="code" href="class_qwt_plot.html#a58">00340</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot.html#a58">QwtPlot::setCurvePen</a>(<span class="keywordtype">long</span> key, <span class="keyword">const</span> QPen &amp;pen)
00341 {
00342     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00343     <span class="keywordflow">if</span> ( !c )
00344         <span class="keywordflow">return</span> FALSE;
00345     
00346     c-&gt;<a class="code" href="class_qwt_curve.html#a21">setPen</a>(pen);
00347     <a class="code" href="class_qwt_plot.html#b9">updateLegendItem</a>(key);
00348 
00349     <span class="keywordflow">return</span> TRUE;
00350 }
00351 
<a name="l00362"></a><a class="code" href="class_qwt_plot.html#a60">00362</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot.html#a60">QwtPlot::setCurveBrush</a>(<span class="keywordtype">long</span> key, <span class="keyword">const</span> QBrush &amp;brush)
00363 {
00364     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00365     <span class="keywordflow">if</span> ( !c )
00366         <span class="keywordflow">return</span> FALSE;
00367     
00368     c-&gt;<a class="code" href="class_qwt_curve.html#a23">setBrush</a>(brush);
00369     <a class="code" href="class_qwt_plot.html#b9">updateLegendItem</a>(key);
00370 
00371     <span class="keywordflow">return</span> TRUE;
00372 }
00373 
<a name="l00380"></a><a class="code" href="class_qwt_plot.html#a66">00380</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot.html#a66">QwtPlot::setCurveSymbol</a>(<span class="keywordtype">long</span> key, <span class="keyword">const</span> <a class="code" href="class_qwt_symbol.html">QwtSymbol</a> &amp;symbol)
00381 {
00382     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00383     <span class="keywordflow">if</span> ( !c )
00384         <span class="keywordflow">return</span> FALSE;
00385 
00386     c-&gt;<a class="code" href="class_qwt_curve.html#a29">setSymbol</a>(symbol);
00387     <a class="code" href="class_qwt_plot.html#b9">updateLegendItem</a>(key);
00388 
00389     <span class="keywordflow">return</span> TRUE;
00390 }
00391 
<a name="l00407"></a><a class="code" href="class_qwt_plot.html#a51">00407</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot.html#a51">QwtPlot::setCurveRawData</a>(<span class="keywordtype">long</span> key, 
00408     <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)
00409 {
00410     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00411     <span class="keywordflow">if</span> ( !c )
00412         <span class="keywordflow">return</span> FALSE;
00413 
00414     c-&gt;<a class="code" href="class_qwt_curve.html#a4">setRawData</a>(xData, yData, size);
00415     <span class="keywordflow">return</span> TRUE;
00416 }
00417 
<a name="l00424"></a><a class="code" href="class_qwt_plot.html#a68">00424</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot.html#a68">QwtPlot::setCurveTitle</a>(<span class="keywordtype">long</span> key, <span class="keyword">const</span> QString &amp;title)
00425 {
00426     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00427     <span class="keywordflow">if</span> ( !c )
00428         <span class="keywordflow">return</span> FALSE;
00429 
00430     c-&gt;<a class="code" href="class_qwt_curve.html#a19">setTitle</a>(title);
00431     <a class="code" href="class_qwt_plot.html#b9">updateLegendItem</a>(key);
00432 
00433     <span class="keywordflow">return</span> TRUE;
00434 }
00435 
<a name="l00449"></a><a class="code" href="class_qwt_plot.html#a52">00449</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot.html#a52">QwtPlot::setCurveData</a>(<span class="keywordtype">long</span> key, 
00450     <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)
00451 {
00452     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00453     <span class="keywordflow">if</span> ( !c )
00454         <span class="keywordflow">return</span> FALSE;
00455 
00456     c-&gt;<a class="code" href="class_qwt_curve.html#a5">setData</a>(xData, yData, size);
00457     <span class="keywordflow">return</span> TRUE;
00458 }
00459     
<a name="l00468"></a><a class="code" href="class_qwt_plot.html#a53">00468</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot.html#a52">QwtPlot::setCurveData</a>(<span class="keywordtype">long</span> key, 
00469     <span class="keyword">const</span> QwtArray&lt;double&gt; &amp;xData, <span class="keyword">const</span> QwtArray&lt;double&gt; &amp;yData)
00470 {
00471     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00472     <span class="keywordflow">if</span> ( !c )
00473         <span class="keywordflow">return</span> FALSE;
00474 
00475     c-&gt;<a class="code" href="class_qwt_curve.html#a5">setData</a>(xData, yData);
00476     <span class="keywordflow">return</span> TRUE;
00477 }
00478     
<a name="l00486"></a><a class="code" href="class_qwt_plot.html#a54">00486</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot.html#a52">QwtPlot::setCurveData</a>(<span class="keywordtype">long</span> key, <span class="keyword">const</span> QwtArray&lt;QwtDoublePoint&gt; &amp;data)
00487 {
00488     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00489     <span class="keywordflow">if</span> ( !c )
00490         <span class="keywordflow">return</span> FALSE;
00491 
00492     c-&gt;<a class="code" href="class_qwt_curve.html#a5">setData</a>(data);
00493     <span class="keywordflow">return</span> TRUE;
00494 }
00495     
<a name="l00503"></a><a class="code" href="class_qwt_plot.html#a55">00503</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot.html#a52">QwtPlot::setCurveData</a>(<span class="keywordtype">long</span> key, <span class="keyword">const</span> <a class="code" href="class_qwt_data.html">QwtData</a> &amp;data)
00504 {
00505     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00506     <span class="keywordflow">if</span> ( !c )
00507         <span class="keywordflow">return</span> FALSE;
00508 
00509     c-&gt;<a class="code" href="class_qwt_curve.html#a5">setData</a>(data);
00510     <span class="keywordflow">return</span> TRUE;
00511 }
00512     
<a name="l00521"></a><a class="code" href="class_qwt_plot.html#a64">00521</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot.html#a64">QwtPlot::setCurveStyle</a>(<span class="keywordtype">long</span> key, <span class="keywordtype">int</span> s, <span class="keywordtype">int</span> options)
00522 {
00523     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00524     <span class="keywordflow">if</span> ( !c )
00525         <span class="keywordflow">return</span> FALSE;
00526 
00527     c-&gt;<a class="code" href="class_qwt_curve.html#a27">setStyle</a>(s, options);
00528     <a class="code" href="class_qwt_plot.html#b9">updateLegendItem</a>(key);
00529 
00530     <span class="keywordflow">return</span> TRUE;
00531 }
00532 
<a name="l00540"></a><a class="code" href="class_qwt_plot.html#a56">00540</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot.html#a56">QwtPlot::setCurveOptions</a>(<span class="keywordtype">long</span> key, <span class="keywordtype">int</span> opt)
00541 {
00542     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00543     <span class="keywordflow">if</span> ( !c )
00544         <span class="keywordflow">return</span> FALSE;
00545 
00546     c-&gt;<a class="code" href="class_qwt_curve.html#a17">setOptions</a>(opt);
00547     <span class="keywordflow">return</span> TRUE;
00548 }
00549 
<a name="l00556"></a><a class="code" href="class_qwt_plot.html#a62">00556</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot.html#a62">QwtPlot::setCurveSplineSize</a>(<span class="keywordtype">long</span> key, <span class="keywordtype">int</span> s)
00557 {
00558     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00559     <span class="keywordflow">if</span> ( !c )
00560         <span class="keywordflow">return</span> FALSE;
00561 
00562     c-&gt;<a class="code" href="class_qwt_curve.html#a31">setSplineSize</a>(s);
00563     <span class="keywordflow">return</span> TRUE;
00564 }
00565 
00566 
<a name="l00573"></a><a class="code" href="class_qwt_plot.html#a70">00573</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot.html#a70">QwtPlot::setCurveXAxis</a>(<span class="keywordtype">long</span> key, <span class="keywordtype">int</span> axis)
00574 {
00575     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00576     <span class="keywordflow">if</span> ( !c )
00577         <span class="keywordflow">return</span> FALSE;
00578 
00579     c-&gt;<a class="code" href="class_qwt_plot_mapped_item.html#a2">setXAxis</a>(axis);
00580     <span class="keywordflow">return</span> TRUE;
00581 }
00582 
<a name="l00589"></a><a class="code" href="class_qwt_plot.html#a72">00589</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot.html#a72">QwtPlot::setCurveYAxis</a>(<span class="keywordtype">long</span> key, <span class="keywordtype">int</span> axis)
00590 {
00591     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00592     <span class="keywordflow">if</span> ( !c )
00593         <span class="keywordflow">return</span> FALSE;
00594 
00595     c-&gt;<a class="code" href="class_qwt_plot_mapped_item.html#a4">setYAxis</a>(axis);
00596     <span class="keywordflow">return</span> TRUE;
00597 }
00598 
00599 
<a name="l00609"></a><a class="code" href="class_qwt_plot.html#a49">00609</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot.html#a49">QwtPlot::setCurveBaseline</a>(<span class="keywordtype">long</span> key, <span class="keywordtype">double</span> ref)
00610 {
00611     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c = d_curves-&gt;find(key);
00612     <span class="keywordflow">if</span> ( !c )
00613         <span class="keywordflow">return</span> FALSE;
00614 
00615     c-&gt;<a class="code" href="class_qwt_curve.html#a25">setBaseline</a>(ref);
00616     <span class="keywordflow">return</span> TRUE;
00617 }
00618 
<a name="l00626"></a><a class="code" href="class_qwt_plot.html#a50">00626</a> <span class="keywordtype">double</span> <a class="code" href="class_qwt_plot.html#a50">QwtPlot::curveBaseline</a>(<span class="keywordtype">long</span> key)<span class="keyword"> const</span>
00627 <span class="keyword"></span>{
00628     <span class="keywordtype">double</span> rv = 0.0;
00629     <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *c;
00630     <span class="keywordflow">if</span> ((c = d_curves-&gt;find(key)))
00631         rv = c-&gt;<a class="code" href="class_qwt_curve.html#a26">baseline</a>();
00632     <span class="keywordflow">return</span> rv;
00633 }
00634 
<a name="l00644"></a><a class="code" href="class_qwt_plot.html#b8">00644</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot.html#b8">QwtPlot::insertLegendItem</a>(<span class="keywordtype">long</span> curveKey)
00645 {
00646     <span class="keywordflow">if</span> ( d_legend-&gt;<a class="code" href="class_qwt_legend.html#a2">isReadOnly</a>() )
00647     {
00648         <a class="code" href="class_qwt_legend_label.html">QwtLegendLabel</a> *label = 
00649             <span class="keyword">new</span> <a class="code" href="class_qwt_legend_label.html">QwtLegendLabel</a>(d_legend-&gt;<a class="code" href="class_qwt_legend.html#a6">contentsWidget</a>());
00650         d_legend-&gt;<a class="code" href="class_qwt_legend.html#a8">insertItem</a>(label, curveKey);
00651     }
00652     <span class="keywordflow">else</span>
00653     {
00654         <a class="code" href="class_qwt_legend_button.html">QwtLegendButton</a> *button = 
00655             <span class="keyword">new</span> <a class="code" href="class_qwt_legend_button.html">QwtLegendButton</a>(d_legend-&gt;<a class="code" href="class_qwt_legend.html#a6">contentsWidget</a>());
00656         connect(button, SIGNAL(clicked()), SLOT(<a class="code" href="class_qwt_plot.html#j0">lgdClicked</a>()));
00657 
00658         d_legend-&gt;<a class="code" href="class_qwt_legend.html#a8">insertItem</a>(button, curveKey);
00659     }
00660 
00661     <a class="code" href="class_qwt_plot.html#b9">updateLegendItem</a>(curveKey);
00662 }
00663 
<a name="l00669"></a><a class="code" href="class_qwt_plot.html#b9">00669</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot.html#b9">QwtPlot::updateLegendItem</a>(<span class="keywordtype">long</span> curveKey)
00670 {
00671     <span class="keyword">const</span> <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *<a class="code" href="class_qwt_plot.html#a44">curve</a> = d_curves-&gt;find(curveKey);
00672     <span class="keywordflow">if</span> ( !curve )
00673         <span class="keywordflow">return</span>;
00674 
00675     QWidget *item = d_legend-&gt;<a class="code" href="class_qwt_legend.html#a9">findItem</a>(curveKey);
00676     <span class="keywordflow">if</span> (item &amp;&amp; item-&gt;inherits(<span class="stringliteral">"QwtLegendButton"</span>)) 
00677     {
00678         <a class="code" href="class_qwt_legend_button.html">QwtLegendButton</a> *button = (<a class="code" href="class_qwt_legend_button.html">QwtLegendButton</a> *)item;
00679 
00680         <span class="keyword">const</span> <span class="keywordtype">bool</span> doUpdate = button-&gt;isUpdatesEnabled();
00681         button-&gt;setUpdatesEnabled(FALSE);
00682 
00683         <a class="code" href="class_qwt_plot.html#b9">updateLegendItem</a>(curve, button);
00684 
00685         button-&gt;setUpdatesEnabled(doUpdate);
00686         button-&gt;update();
00687     }
00688     <span class="keywordflow">if</span> (item &amp;&amp; item-&gt;inherits(<span class="stringliteral">"QwtLegendLabel"</span>)) 
00689     {
00690         <a class="code" href="class_qwt_legend_label.html">QwtLegendLabel</a> *label = (<a class="code" href="class_qwt_legend_label.html">QwtLegendLabel</a> *)item;
00691 
00692         <span class="keyword">const</span> <span class="keywordtype">bool</span> doUpdate = label-&gt;isUpdatesEnabled();
00693         label-&gt;setUpdatesEnabled(FALSE);
00694 
00695         <a class="code" href="class_qwt_plot.html#b9">updateLegendItem</a>(curve, label);
00696 
00697         label-&gt;setUpdatesEnabled(doUpdate);
00698         label-&gt;update();
00699     }
00700 }
00701 
<a name="l00708"></a><a class="code" href="class_qwt_plot.html#b11">00708</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot.html#b9">QwtPlot::updateLegendItem</a>(
00709     <span class="keyword">const</span> <a class="code" href="class_qwt_plot_curve.html">QwtPlotCurve</a> *curve, <a class="code" href="class_qwt_legend_item.html">QwtLegendItem</a> *item)
00710 {
00711     <span class="keywordflow">if</span> ( !curve || !item )
00712         <span class="keywordflow">return</span>;
00713 
00714     <span class="keywordtype">int</span> policy = d_legend-&gt;<a class="code" href="class_qwt_legend.html#a4">displayPolicy</a>();
00715 
00716     <span class="keywordflow">if</span> (policy == QwtLegend::Fixed) 
00717     {
00718         <span class="keywordtype">int</span> mode = d_legend-&gt;<a class="code" href="class_qwt_legend.html#a5">identifierMode</a>();
00719 
00720         <span class="keywordflow">if</span> (mode &amp; QwtLegendButton::ShowLine) 
00721             item-&gt;<a class="code" href="class_qwt_legend_item.html#a7">setCurvePen</a>(curve-&gt;<a class="code" href="class_qwt_curve.html#a22">pen</a>());
00722 
00723         <span class="keywordflow">if</span> (mode &amp; QwtLegendButton::ShowSymbol) 
00724             item-&gt;<a class="code" href="class_qwt_legend_item.html#a5">setSymbol</a>(curve-&gt;<a class="code" href="class_qwt_curve.html#a30">symbol</a>());
00725 
00726         <span class="keywordflow">if</span> (mode &amp; QwtLegendButton::ShowText) 
00727             item-&gt;<a class="code" href="class_qwt_legend_item.html#a11">setTitle</a>(curve-&gt;<a class="code" href="class_qwt_curve.html#a20">title</a>());
00728         <span class="keywordflow">else</span> 
00729             item-&gt;<a class="code" href="class_qwt_legend_item.html#a11">setTitle</a>(QString::null);
00730 
00731         item-&gt;<a class="code" href="class_qwt_legend_item.html#a3">setIdentifierMode</a>(mode);
00732     } 
00733     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (policy == QwtLegend::Auto) 
00734     {
00735         <span class="keywordtype">int</span> mode = 0;
00736 
00737         <span class="keywordflow">if</span> (QwtCurve::NoCurve != curve-&gt;<a class="code" href="class_qwt_curve.html#a28">style</a>()) 
00738         {
00739             item-&gt;<a class="code" href="class_qwt_legend_item.html#a7">setCurvePen</a>(curve-&gt;<a class="code" href="class_qwt_curve.html#a22">pen</a>());
00740             mode |= QwtLegendButton::ShowLine;
00741         }
00742         <span class="keywordflow">if</span> (QwtSymbol::None != curve-&gt;<a class="code" href="class_qwt_curve.html#a30">symbol</a>().<a class="code" href="class_qwt_symbol.html#a13">style</a>()) 
00743         {
00744             item-&gt;<a class="code" href="class_qwt_legend_item.html#a5">setSymbol</a>(curve-&gt;<a class="code" href="class_qwt_curve.html#a30">symbol</a>());
00745             mode |= QwtLegendButton::ShowSymbol;
00746         }
00747         <span class="keywordflow">if</span> ( !curve-&gt;<a class="code" href="class_qwt_curve.html#a20">title</a>().isEmpty() )
00748         { 
00749             item-&gt;<a class="code" href="class_qwt_legend_item.html#a11">setTitle</a>(curve-&gt;<a class="code" href="class_qwt_curve.html#a20">title</a>());
00750             mode |= QwtLegendButton::ShowText;
00751         } 
00752         <span class="keywordflow">else</span> 
00753         {
00754             item-&gt;<a class="code" href="class_qwt_legend_item.html#a11">setTitle</a>(QString::null);
00755         }
00756         item-&gt;<a class="code" href="class_qwt_legend_item.html#a3">setIdentifierMode</a>(mode);
00757     }
00758 }
00759 
00760 <span class="comment">// Local Variables:</span>
00761 <span class="comment">// mode: C++</span>
00762 <span class="comment">// c-file-style: "stroustrup"</span>
00763 <span class="comment">// indent-tabs-mode: nil</span>
00764 <span class="comment">// End:</span>
</div></pre><hr size="1"><address style="align: right;"><small>Generated on Tue Nov 16 21:12:20 2004 for Qwt User's Guide by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.8 </small></address>
</body>
</html>