File: qwt__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 (626 lines) | stat: -rw-r--r-- 42,171 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
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
<!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_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_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 &lt;qpainter.h&gt;</span>
00011 <span class="preprocessor">#include "qwt_global.h"</span>
00012 <span class="preprocessor">#include "qwt_curve.h"</span>
00013 <span class="preprocessor">#include "qwt_data.h"</span>
00014 <span class="preprocessor">#include "qwt_dimap.h"</span>
00015 <span class="preprocessor">#include "qwt_double_rect.h"</span>
00016 <span class="preprocessor">#include "<a class="code" href="qwt__math_8h.html">qwt_math.h</a>"</span>
00017 <span class="preprocessor">#include "qwt_painter.h"</span>
00018 
<a name="l00022"></a><a class="code" href="class_qwt_curve.html#b0">00022</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#b0">QwtCurve::init</a>(<span class="keyword">const</span> QString &amp;title)
00023 {
00024     d_pen = QPen(Qt::black, 1);
00025     d_ref = 0.0;
00026     d_splineSize = 250;
00027     d_options = Auto;
00028     d_title = title;
00029     d_style = Lines;
00030     d_data = <span class="keyword">new</span> <a class="code" href="class_qwt_double_point_data.html">QwtDoublePointData</a>(QwtArray&lt;QwtDoublePoint&gt;());
00031 }
00032 
<a name="l00036"></a><a class="code" href="class_qwt_curve.html#b1">00036</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#b1">QwtCurve::copy</a>(<span class="keyword">const</span> <a class="code" href="class_qwt_curve.html">QwtCurve</a> &amp;c)
00037 {
00038     d_ref = c.<a class="code" href="class_qwt_curve.html#r2">d_ref</a>;
00039     d_sym = c.<a class="code" href="class_qwt_curve.html#r3">d_sym</a>;
00040     d_pen = c.<a class="code" href="class_qwt_curve.html#r4">d_pen</a>;
00041     d_title = c.<a class="code" href="class_qwt_curve.html#r6">d_title</a>;
00042     d_style = c.<a class="code" href="class_qwt_curve.html#r1">d_style</a>;
00043 
00044     d_splineSize = c.<a class="code" href="class_qwt_curve.html#r8">d_splineSize</a>;
00045     d_options = c.<a class="code" href="class_qwt_curve.html#r7">d_options</a>;
00046 
00047     <span class="keyword">delete</span> d_data;
00048     d_data = c.<a class="code" href="class_qwt_curve.html#r0">d_data</a>-&gt;<a class="code" href="class_qwt_data.html#a2">copy</a>();
00049 }
00050 
<a name="l00052"></a><a class="code" href="class_qwt_curve.html#a2">00052</a> <a class="code" href="class_qwt_curve.html#a2">QwtCurve::~QwtCurve</a>()
00053 {
00054     <span class="keyword">delete</span> d_data;
00055 }
00056 
<a name="l00060"></a><a class="code" href="class_qwt_curve.html#a1">00060</a> <a class="code" href="class_qwt_curve.html#a0">QwtCurve::QwtCurve</a>(<span class="keyword">const</span> <a class="code" href="class_qwt_curve.html">QwtCurve</a> &amp;c)
00061 {
00062     <a class="code" href="class_qwt_curve.html#b0">init</a>(c.<a class="code" href="class_qwt_curve.html#r6">d_title</a>);
00063     <a class="code" href="class_qwt_curve.html#b1">copy</a>(c);
00064 }
00065 
<a name="l00069"></a><a class="code" href="class_qwt_curve.html#a3">00069</a> <span class="keyword">const</span> <a class="code" href="class_qwt_curve.html">QwtCurve</a>&amp; <a class="code" href="class_qwt_curve.html#a3">QwtCurve::operator=</a>(<span class="keyword">const</span> <a class="code" href="class_qwt_curve.html">QwtCurve</a> &amp;c)
00070 {
00071     <span class="keywordflow">if</span> (<span class="keyword">this</span> != &amp;c)
00072     {
00073         <a class="code" href="class_qwt_curve.html#b1">copy</a>(c);
00074         <a class="code" href="class_qwt_curve.html#b10">curveChanged</a>();
00075     }
00076 
00077     <span class="keywordflow">return</span> *<span class="keyword">this</span>;
00078 }
00079 
<a name="l00110"></a><a class="code" href="class_qwt_curve.html#a27">00110</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#a27">QwtCurve::setStyle</a>(<span class="keywordtype">int</span> style, <span class="keywordtype">int</span> options)
00111 {
00112     d_options = options;
00113     d_style = style;
00114     <a class="code" href="class_qwt_curve.html#b10">curveChanged</a>();
00115 }
00116 
<a name="l00122"></a><a class="code" href="class_qwt_curve.html#a28">00122</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_curve.html#a28">QwtCurve::style</a>()<span class="keyword"> const </span>
00123 <span class="keyword"></span>{ 
00124     <span class="keywordflow">return</span> d_style; 
00125 }
00126 
<a name="l00132"></a><a class="code" href="class_qwt_curve.html#a29">00132</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#a29">QwtCurve::setSymbol</a>(<span class="keyword">const</span> <a class="code" href="class_qwt_symbol.html">QwtSymbol</a> &amp;s )
00133 {
00134     d_sym = s;
00135     <a class="code" href="class_qwt_curve.html#b10">curveChanged</a>();
00136 }
00137 
<a name="l00142"></a><a class="code" href="class_qwt_curve.html#a30">00142</a> <span class="keyword">const</span> <a class="code" href="class_qwt_symbol.html">QwtSymbol</a> &amp;<a class="code" href="class_qwt_curve.html#a30">QwtCurve::symbol</a>()<span class="keyword"> const </span>
00143 <span class="keyword"></span>{ 
00144     <span class="keywordflow">return</span> d_sym; 
00145 }
00146 
00147 
<a name="l00152"></a><a class="code" href="class_qwt_curve.html#a21">00152</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#a21">QwtCurve::setPen</a>(<span class="keyword">const</span> QPen &amp;p)
00153 {
00154     <span class="keywordflow">if</span> ( p != d_pen )
00155     {
00156         d_pen = p;
00157         <a class="code" href="class_qwt_curve.html#b10">curveChanged</a>();
00158     }
00159 }
00160 
<a name="l00165"></a><a class="code" href="class_qwt_curve.html#a22">00165</a> <span class="keyword">const</span> QPen&amp; <a class="code" href="class_qwt_curve.html#a22">QwtCurve::pen</a>()<span class="keyword"> const </span>
00166 <span class="keyword"></span>{ 
00167     <span class="keywordflow">return</span> d_pen; 
00168 }
00169 
<a name="l00182"></a><a class="code" href="class_qwt_curve.html#a23">00182</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#a23">QwtCurve::setBrush</a>(<span class="keyword">const</span> QBrush &amp;brush)
00183 {
00184     <span class="keywordflow">if</span> ( brush != d_brush )
00185     {
00186         d_brush = brush;
00187         <a class="code" href="class_qwt_curve.html#b10">curveChanged</a>();
00188     }
00189 }
00190 
<a name="l00196"></a><a class="code" href="class_qwt_curve.html#a24">00196</a> <span class="keyword">const</span> QBrush&amp; <a class="code" href="class_qwt_curve.html#a24">QwtCurve::brush</a>()<span class="keyword"> const </span>
00197 <span class="keyword"></span>{
00198     <span class="keywordflow">return</span> d_brush;
00199 }
00200 
00201 
<a name="l00213"></a><a class="code" href="class_qwt_curve.html#a5">00213</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#a5">QwtCurve::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)
00214 {
00215     <span class="keyword">delete</span> d_data;
00216     d_data = <span class="keyword">new</span> <a class="code" href="class_qwt_array_data.html">QwtArrayData</a>(xData, yData, size);
00217     <a class="code" href="class_qwt_curve.html#b10">curveChanged</a>();
00218 }
00219 
<a name="l00228"></a><a class="code" href="class_qwt_curve.html#a6">00228</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#a5">QwtCurve::setData</a>(<span class="keyword">const</span> QwtArray&lt;double&gt; &amp;xData, 
00229     <span class="keyword">const</span> QwtArray&lt;double&gt; &amp;yData)
00230 {
00231     <span class="keyword">delete</span> d_data;
00232     d_data = <span class="keyword">new</span> <a class="code" href="class_qwt_array_data.html">QwtArrayData</a>(xData, yData);
00233     <a class="code" href="class_qwt_curve.html#b10">curveChanged</a>();
00234 }
00235 
<a name="l00243"></a><a class="code" href="class_qwt_curve.html#a7">00243</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#a5">QwtCurve::setData</a>(<span class="keyword">const</span> QwtArray&lt;QwtDoublePoint&gt; &amp;data)
00244 {
00245     <span class="keyword">delete</span> d_data;
00246     d_data = <span class="keyword">new</span> <a class="code" href="class_qwt_double_point_data.html">QwtDoublePointData</a>(data);
00247     <a class="code" href="class_qwt_curve.html#b10">curveChanged</a>();
00248 }
00249 
<a name="l00257"></a><a class="code" href="class_qwt_curve.html#a8">00257</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#a5">QwtCurve::setData</a>(<span class="keyword">const</span> <a class="code" href="class_qwt_data.html">QwtData</a> &amp;data)
00258 {
00259     <span class="keyword">delete</span> d_data;
00260     d_data = data.<a class="code" href="class_qwt_data.html#a2">copy</a>();
00261     <a class="code" href="class_qwt_curve.html#b10">curveChanged</a>();
00262 }
00263 
<a name="l00277"></a><a class="code" href="class_qwt_curve.html#a4">00277</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#a4">QwtCurve::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)
00278 {
00279     <span class="keyword">delete</span> d_data;
00280     d_data = <span class="keyword">new</span> <a class="code" href="class_qwt_c_pointer_data.html">QwtCPointerData</a>(xData, yData, size);
00281     <a class="code" href="class_qwt_curve.html#b10">curveChanged</a>();
00282 }
00283 
<a name="l00288"></a><a class="code" href="class_qwt_curve.html#a19">00288</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#a19">QwtCurve::setTitle</a>(<span class="keyword">const</span> QString &amp;title)
00289 {
00290     d_title = title;
00291     <a class="code" href="class_qwt_curve.html#b10">curveChanged</a>();
00292 }
00293 
<a name="l00298"></a><a class="code" href="class_qwt_curve.html#a20">00298</a> <span class="keyword">const</span> QString &amp;<a class="code" href="class_qwt_curve.html#a20">QwtCurve::title</a>()<span class="keyword"> const </span>
00299 <span class="keyword"></span>{ 
00300     <span class="keywordflow">return</span> d_title; 
00301 }
00302 
<a name="l00309"></a><a class="code" href="class_qwt_curve.html#a12">00309</a> <a class="code" href="class_qwt_double_rect.html">QwtDoubleRect</a> <a class="code" href="class_qwt_curve.html#a12">QwtCurve::boundingRect</a>()<span class="keyword"> const</span>
00310 <span class="keyword"></span>{
00311     <span class="keywordflow">if</span> ( d_data == NULL )
00312         <span class="keywordflow">return</span> <a class="code" href="class_qwt_double_rect.html">QwtDoubleRect</a>(1.0, -1.0, 1.0, -1.0); <span class="comment">// invalid</span>
00313 
00314     <span class="keywordflow">return</span> d_data-&gt;<a class="code" href="class_qwt_data.html#a6">boundingRect</a>();
00315 }
00316 
<a name="l00321"></a><a class="code" href="class_qwt_curve.html#a0">00321</a> <a class="code" href="class_qwt_curve.html#a0">QwtCurve::QwtCurve</a>(<span class="keyword">const</span> QString &amp;title)
00322 {
00323     <a class="code" href="class_qwt_curve.html#b0">init</a>(title);
00324 }
00325 
<a name="l00331"></a><a class="code" href="class_qwt_curve.html#b11">00331</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_curve.html#b11">QwtCurve::verifyRange</a>(<span class="keywordtype">int</span> &amp;i1, <span class="keywordtype">int</span> &amp;i2)
00332 {
00333     <span class="keywordtype">int</span> size = <a class="code" href="class_qwt_curve.html#a9">dataSize</a>();
00334 
00335     <span class="keywordflow">if</span> (size &lt; 1) <span class="keywordflow">return</span> 0;
00336 
00337     i1 = <a class="code" href="qwt__math_8h.html#a37">qwtLim</a>(i1, 0, size-1);
00338     i2 = <a class="code" href="qwt__math_8h.html#a37">qwtLim</a>(i2, 0, size-1);
00339     <a class="code" href="qwt__math_8h.html#a36">qwtSort</a>(i1, i2, i1, i2);
00340 
00341     <span class="keywordflow">return</span> (i2 - i1 + 1);
00342 }
00343 
<a name="l00357"></a><a class="code" href="class_qwt_curve.html#a33">00357</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#a33">QwtCurve::draw</a>(QPainter *painter,
00358     <span class="keyword">const</span> <a class="code" href="class_qwt_di_map.html">QwtDiMap</a> &amp;xMap, <span class="keyword">const</span> <a class="code" href="class_qwt_di_map.html">QwtDiMap</a> &amp;yMap, <span class="keywordtype">int</span> from, <span class="keywordtype">int</span> to)
00359 {
00360     <span class="keywordflow">if</span> ( !painter || <a class="code" href="class_qwt_curve.html#a9">dataSize</a>() &lt;= 0 )
00361         <span class="keywordflow">return</span>;
00362 
00363     <span class="keywordflow">if</span> (to &lt; 0)
00364         to = <a class="code" href="class_qwt_curve.html#a9">dataSize</a>() - 1;
00365 
00366     <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_curve.html#b11">verifyRange</a>(from, to) &gt; 0 )
00367     {
00368         painter-&gt;save();
00369         painter-&gt;setPen(d_pen);
00370 
00371         QBrush b = d_brush;
00372         <span class="keywordflow">if</span> ( b.style() != Qt::NoBrush &amp;&amp; !b.color().isValid() )
00373             b.setColor(d_pen.color());
00374 
00375         painter-&gt;setBrush(b);
00376 
00377         <a class="code" href="class_qwt_curve.html#b2">drawCurve</a>(painter, d_style, xMap, yMap, from, to);
00378         painter-&gt;restore();
00379 
00380         <span class="keywordflow">if</span> (d_sym.<a class="code" href="class_qwt_symbol.html#a13">style</a>() != QwtSymbol::None)
00381         {
00382             painter-&gt;save();
00383             <a class="code" href="class_qwt_curve.html#b3">drawSymbols</a>(painter, d_sym, xMap, yMap, from, to);
00384             painter-&gt;restore();
00385         }
00386     }
00387 }
00388 
<a name="l00401"></a><a class="code" href="class_qwt_curve.html#b2">00401</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#b2">QwtCurve::drawCurve</a>(QPainter *painter, <span class="keywordtype">int</span> style,
00402     <span class="keyword">const</span> <a class="code" href="class_qwt_di_map.html">QwtDiMap</a> &amp;xMap, <span class="keyword">const</span> <a class="code" href="class_qwt_di_map.html">QwtDiMap</a> &amp;yMap, <span class="keywordtype">int</span> from, <span class="keywordtype">int</span> to)
00403 {
00404     <span class="keywordflow">switch</span> (style)
00405     {
00406         <span class="keywordflow">case</span> NoCurve:
00407             <span class="keywordflow">break</span>;
00408         <span class="keywordflow">case</span> Lines:
00409             <a class="code" href="class_qwt_curve.html#b4">drawLines</a>(painter, xMap, yMap, from, to);
00410             <span class="keywordflow">break</span>;
00411         <span class="keywordflow">case</span> Sticks:
00412             <a class="code" href="class_qwt_curve.html#b5">drawSticks</a>(painter, xMap, yMap, from, to);
00413             <span class="keywordflow">break</span>;
00414         <span class="keywordflow">case</span> Steps:
00415             <a class="code" href="class_qwt_curve.html#b7">drawSteps</a>(painter, xMap, yMap, from, to);
00416             <span class="keywordflow">break</span>;
00417         <span class="keywordflow">case</span> Spline:
00418             <span class="keywordflow">if</span> ( from &gt; 0 || to &lt; <a class="code" href="class_qwt_curve.html#a9">dataSize</a>() - 1 )
00419                 <a class="code" href="class_qwt_curve.html#b4">drawLines</a>(painter, xMap, yMap, from, to);
00420             <span class="keywordflow">else</span>
00421                 <a class="code" href="class_qwt_curve.html#b8">drawSpline</a>(painter, xMap, yMap);
00422             <span class="keywordflow">break</span>;
00423         <span class="keywordflow">case</span> Dots:
00424             <a class="code" href="class_qwt_curve.html#b6">drawDots</a>(painter, xMap, yMap, from, to);
00425             <span class="keywordflow">break</span>;
00426         <span class="keywordflow">default</span>:
00427             <span class="keywordflow">break</span>;
00428     }
00429 }
00430 
<a name="l00441"></a><a class="code" href="class_qwt_curve.html#b4">00441</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#b4">QwtCurve::drawLines</a>(QPainter *painter,
00442     <span class="keyword">const</span> <a class="code" href="class_qwt_di_map.html">QwtDiMap</a> &amp;xMap, <span class="keyword">const</span> <a class="code" href="class_qwt_di_map.html">QwtDiMap</a> &amp;yMap, <span class="keywordtype">int</span> from, <span class="keywordtype">int</span> to)
00443 {
00444     QPointArray polyline(to - from + 1);
00445     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = from; i &lt;= to; i++)
00446     {
00447         <span class="keywordtype">int</span> xi = xMap.<a class="code" href="class_qwt_di_map.html#a7">transform</a>(<a class="code" href="class_qwt_curve.html#a10">x</a>(i));
00448         <span class="keywordtype">int</span> yi = yMap.<a class="code" href="class_qwt_di_map.html#a7">transform</a>(<a class="code" href="class_qwt_curve.html#a11">y</a>(i));
00449 
00450         polyline.setPoint(i - from, xi, yi);
00451     }
00452 
00453     <a class="code" href="class_qwt_painter.html#e19">QwtPainter::drawPolyline</a>(painter, polyline);
00454 
00455     <span class="keywordflow">if</span> ( painter-&gt;brush().style() != Qt::NoBrush )
00456     {
00457         <a class="code" href="class_qwt_curve.html#b9">closePolyline</a>(xMap, yMap, polyline);
00458         painter-&gt;setPen(QPen(Qt::NoPen));
00459         <a class="code" href="class_qwt_painter.html#e18">QwtPainter::drawPolygon</a>(painter, polyline);
00460     }
00461 }
00462 
<a name="l00473"></a><a class="code" href="class_qwt_curve.html#b5">00473</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#b5">QwtCurve::drawSticks</a>(QPainter *painter,
00474     <span class="keyword">const</span> <a class="code" href="class_qwt_di_map.html">QwtDiMap</a> &amp;xMap, <span class="keyword">const</span> <a class="code" href="class_qwt_di_map.html">QwtDiMap</a> &amp;yMap, <span class="keywordtype">int</span> from, <span class="keywordtype">int</span> to)
00475 {
00476     <span class="keywordtype">int</span> x0 = xMap.<a class="code" href="class_qwt_di_map.html#a7">transform</a>(d_ref);
00477     <span class="keywordtype">int</span> y0 = yMap.<a class="code" href="class_qwt_di_map.html#a7">transform</a>(d_ref);
00478 
00479     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = from; i &lt;= to; i++)
00480     {
00481         <span class="keywordtype">int</span> xi = xMap.<a class="code" href="class_qwt_di_map.html#a7">transform</a>(<a class="code" href="class_qwt_curve.html#a10">x</a>(i));
00482         <span class="keywordtype">int</span> yi = yMap.<a class="code" href="class_qwt_di_map.html#a7">transform</a>(<a class="code" href="class_qwt_curve.html#a11">y</a>(i));
00483 
00484         <span class="keywordflow">if</span> (d_options &amp; Xfy)
00485             <a class="code" href="class_qwt_painter.html#e16">QwtPainter::drawLine</a>(painter, x0, yi, xi, yi);
00486         <span class="keywordflow">else</span>
00487             <a class="code" href="class_qwt_painter.html#e16">QwtPainter::drawLine</a>(painter, xi, y0, xi, yi);
00488     }
00489 }
00490 
<a name="l00502"></a><a class="code" href="class_qwt_curve.html#b6">00502</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#b6">QwtCurve::drawDots</a>(QPainter *painter,
00503     <span class="keyword">const</span> <a class="code" href="class_qwt_di_map.html">QwtDiMap</a> &amp;xMap, <span class="keyword">const</span> <a class="code" href="class_qwt_di_map.html">QwtDiMap</a> &amp;yMap, <span class="keywordtype">int</span> from, <span class="keywordtype">int</span> to)
00504 {
00505     <span class="keyword">const</span> <span class="keywordtype">bool</span> doFill = painter-&gt;brush().style() != Qt::NoBrush;
00506 
00507     QPointArray polyline;
00508     <span class="keywordflow">if</span> ( doFill )
00509         polyline.resize(to - from + 1);
00510 
00511     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = from; i &lt;= to; i++)
00512     {
00513         <span class="keywordtype">int</span> xi = xMap.<a class="code" href="class_qwt_di_map.html#a7">transform</a>(<a class="code" href="class_qwt_curve.html#a10">x</a>(i));
00514         <span class="keywordtype">int</span> yi = yMap.<a class="code" href="class_qwt_di_map.html#a7">transform</a>(<a class="code" href="class_qwt_curve.html#a11">y</a>(i));
00515         <a class="code" href="class_qwt_painter.html#e20">QwtPainter::drawPoint</a>(painter, xi, yi);
00516 
00517         <span class="keywordflow">if</span> ( doFill )
00518             polyline.setPoint(i - from, xi, yi);
00519     }
00520 
00521     <span class="keywordflow">if</span> ( doFill )
00522     {
00523         <a class="code" href="class_qwt_curve.html#b9">closePolyline</a>(xMap, yMap, polyline);
00524         painter-&gt;setPen(QPen(Qt::NoPen));
00525         <a class="code" href="class_qwt_painter.html#e18">QwtPainter::drawPolygon</a>(painter, polyline);
00526     }
00527 }
00528 
<a name="l00539"></a><a class="code" href="class_qwt_curve.html#b7">00539</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#b7">QwtCurve::drawSteps</a>(QPainter *painter,
00540     <span class="keyword">const</span> <a class="code" href="class_qwt_di_map.html">QwtDiMap</a> &amp;xMap, <span class="keyword">const</span> <a class="code" href="class_qwt_di_map.html">QwtDiMap</a> &amp;yMap, <span class="keywordtype">int</span> from, <span class="keywordtype">int</span> to)
00541 {
00542     QPointArray polyline(2 * (to - from) + 1);
00543 
00544     <span class="keywordtype">bool</span> inverted = d_options &amp; Yfx;
00545     <span class="keywordflow">if</span> ( d_options &amp; Inverted )
00546         inverted = !inverted;
00547 
00548     <span class="keywordtype">int</span> i,ip;
00549     <span class="keywordflow">for</span> (i = from, ip = 0; i &lt;= to; i++, ip += 2)
00550     {
00551         <span class="keywordtype">int</span> xi = xMap.<a class="code" href="class_qwt_di_map.html#a7">transform</a>(<a class="code" href="class_qwt_curve.html#a10">x</a>(i));
00552         <span class="keywordtype">int</span> yi = yMap.<a class="code" href="class_qwt_di_map.html#a7">transform</a>(<a class="code" href="class_qwt_curve.html#a11">y</a>(i));
00553 
00554         <span class="keywordflow">if</span> ( ip &gt; 0 )
00555         {
00556             <span class="keywordflow">if</span> (inverted)
00557                 polyline.setPoint(ip - 1, polyline[ip-2].<a class="code" href="class_qwt_curve.html#a10">x</a>(), yi);
00558             <span class="keywordflow">else</span>
00559                 polyline.setPoint(ip - 1, xi, polyline[ip-2].<a class="code" href="class_qwt_curve.html#a11">y</a>());
00560         }
00561 
00562         polyline.setPoint(ip, xi, yi);
00563     }
00564 
00565     <a class="code" href="class_qwt_painter.html#e19">QwtPainter::drawPolyline</a>(painter, polyline);
00566 
00567     <span class="keywordflow">if</span> ( painter-&gt;brush().style() != Qt::NoBrush )
00568     {
00569         <a class="code" href="class_qwt_curve.html#b9">closePolyline</a>(xMap, yMap, polyline);
00570         painter-&gt;setPen(QPen(Qt::NoPen));
00571         <a class="code" href="class_qwt_painter.html#e18">QwtPainter::drawPolygon</a>(painter, polyline);
00572     }
00573 }
00574 
<a name="l00583"></a><a class="code" href="class_qwt_curve.html#b8">00583</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#b8">QwtCurve::drawSpline</a>(QPainter *painter,
00584     <span class="keyword">const</span> <a class="code" href="class_qwt_di_map.html">QwtDiMap</a> &amp;xMap, <span class="keyword">const</span> <a class="code" href="class_qwt_di_map.html">QwtDiMap</a> &amp;yMap)
00585 {
00586     <span class="keyword">register</span> <span class="keywordtype">int</span> i;
00587 
00588     <span class="keywordtype">int</span> size = <a class="code" href="class_qwt_curve.html#a9">dataSize</a>();
00589     <span class="keywordtype">double</span> *txval = <span class="keyword">new</span> <span class="keywordtype">double</span>[size];
00590     <span class="keywordtype">double</span> *tyval = <span class="keyword">new</span> <span class="keywordtype">double</span>[size];
00591 
00592 
00593     <span class="keywordflow">if</span> ( !txval || !tyval )
00594     {
00595         <span class="keywordflow">if</span> (txval) <span class="keyword">delete</span>[] txval;
00596         <span class="keywordflow">if</span> (tyval) <span class="keyword">delete</span>[] tyval;
00597         <span class="keywordflow">return</span>;
00598     }
00599 
00600     QPointArray polyline(d_splineSize);
00601 
00602     <span class="comment">//</span>
00603     <span class="comment">// Transform x and y values to window coordinates</span>
00604     <span class="comment">// to avoid a distinction between linear and</span>
00605     <span class="comment">// logarithmic scales.</span>
00606     <span class="comment">//</span>
00607     <span class="keywordflow">for</span> (i=0;i&lt;size;i++)
00608     {
00609         txval[i] = xMap.<a class="code" href="class_qwt_di_map.html#a10">xTransform</a>(<a class="code" href="class_qwt_curve.html#a10">x</a>(i));
00610         tyval[i] = yMap.<a class="code" href="class_qwt_di_map.html#a10">xTransform</a>(<a class="code" href="class_qwt_curve.html#a11">y</a>(i));
00611     }
00612 
00613     <span class="keywordtype">int</span> stype;
00614     <span class="keywordflow">if</span> (! (d_options &amp; (Yfx|Xfy|Parametric)))
00615     {
00616         <span class="keywordflow">if</span> (qwtChkMono(txval, size))
00617         {
00618             stype = Yfx;
00619         }
00620         <span class="keywordflow">else</span>
00621         {
00622             <span class="keywordflow">if</span>(qwtChkMono(tyval, size))
00623             {
00624                 stype = Xfy;
00625             }
00626             <span class="keywordflow">else</span>
00627             {
00628                 stype = Parametric;
00629                 <span class="keywordflow">if</span> ( (d_options &amp; Periodic) ||
00630                     ( (<a class="code" href="class_qwt_curve.html#a10">x</a>(0) == <a class="code" href="class_qwt_curve.html#a10">x</a>(size-1))
00631                     &amp;&amp; (<a class="code" href="class_qwt_curve.html#a11">y</a>(0) == <a class="code" href="class_qwt_curve.html#a11">y</a>(size-1))))
00632                 {
00633                     stype |= Periodic;
00634                 }
00635             }
00636         }
00637     }
00638     <span class="keywordflow">else</span>
00639     {
00640         stype = d_options;
00641     }
00642 
00643     <span class="keywordflow">if</span> (stype &amp; Parametric)
00644     {
00645         <span class="keywordtype">double</span> *param = <span class="keyword">new</span> <span class="keywordtype">double</span>[size];
00646         <span class="keywordflow">if</span> (param)
00647         {
00648             <span class="comment">//</span>
00649             <span class="comment">// setup parameter vector</span>
00650             <span class="comment">//</span>
00651             param[0] = 0.0;
00652             <span class="keywordflow">for</span> (i=1; i&lt;size; i++)
00653             {
00654                 <span class="keywordtype">double</span> delta = sqrt( <a class="code" href="qwt__math_8h.html#a31">qwtSqr</a>(txval[i] - txval[i-1])
00655                               + <a class="code" href="qwt__math_8h.html#a31">qwtSqr</a>( tyval[i] - tyval[i-1]));
00656                 param[i] = param[i-1] + qwtMax(delta, 1.0);
00657             }
00658 
00659             <span class="comment">//</span>
00660             <span class="comment">// setup splines</span>
00661             <span class="keywordtype">int</span> rc = d_spx.<a class="code" href="class_qwt_spline.html#a3">recalc</a>(param, txval, size, stype &amp; Periodic);
00662             <span class="keywordflow">if</span> (!rc)
00663                 rc = d_spy.<a class="code" href="class_qwt_spline.html#a3">recalc</a>(param, tyval, size, stype &amp; Periodic);
00664 
00665             <span class="keywordflow">if</span> (rc)
00666             {
00667                 <a class="code" href="class_qwt_curve.html#b4">drawLines</a>(painter, xMap, yMap, 0, size - 1);
00668             }
00669             <span class="keywordflow">else</span>
00670             {
00671                 <span class="comment">// fill point array</span>
00672                 <span class="keywordtype">double</span> delta = param[size - 1] / double(d_splineSize-1);
00673                 <span class="keywordflow">for</span> (i=0;i&lt;d_splineSize;i++)
00674                 {
00675                     <span class="keywordtype">double</span> dtmp = delta * double(i);
00676                     polyline.setPoint(i, <span class="keywordtype">int</span>(floor (d_spx.<a class="code" href="class_qwt_spline.html#a2">value</a>(dtmp) + 0.5)),
00677                                   int(floor (d_spy.<a class="code" href="class_qwt_spline.html#a2">value</a>(dtmp) + 0.5)));
00678                 }
00679             }
00680 
00681             <span class="keyword">delete</span>[] param;
00682         }
00683     }
00684     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (stype &amp; Xfy)
00685     {
00686         <span class="keywordflow">if</span> (tyval[size-1] &lt; tyval[0])
00687         {
00688             qwtTwistArray(txval, size);
00689             qwtTwistArray(tyval, size);
00690         }
00691 
00692         <span class="comment">// 1. Calculate spline coefficients</span>
00693         <span class="keywordtype">int</span> rc = d_spx.<a class="code" href="class_qwt_spline.html#a3">recalc</a>(tyval, txval, size, stype &amp; Periodic);
00694         <span class="keywordflow">if</span> (rc)                         <span class="comment">// an error occurred</span>
00695         {
00696             <a class="code" href="class_qwt_curve.html#b4">drawLines</a>(painter, xMap, yMap, 0, size - 1);
00697         }
00698         <span class="keywordflow">else</span>                            <span class="comment">// Spline OK</span>
00699         {
00700             <span class="keywordtype">double</span> ymin = qwtGetMin(tyval, size);
00701             <span class="keywordtype">double</span> ymax = qwtGetMax(tyval, size);
00702             <span class="keywordtype">double</span> delta = (ymax - ymin) / double(d_splineSize - 1);
00703 
00704             <span class="keywordflow">for</span> (i=0;i&lt;d_splineSize;i++)
00705             {
00706                 <span class="keywordtype">double</span> dtmp = ymin + delta * double(i);
00707                 polyline.setPoint(i, <span class="keywordtype">int</span>(floor(d_spx.<a class="code" href="class_qwt_spline.html#a2">value</a>(dtmp) + 0.5)),
00708                               int(floor(dtmp + 0.5)));
00709             }
00710         }
00711     }
00712     <span class="keywordflow">else</span>
00713     {
00714         <span class="keywordflow">if</span> (txval[size-1] &lt; txval[0])
00715         {
00716             qwtTwistArray(tyval, size);
00717             qwtTwistArray(txval, size);
00718         }
00719 
00720 
00721         <span class="comment">// 1. Calculate spline coefficients</span>
00722         <span class="keywordtype">int</span> rc = d_spy.<a class="code" href="class_qwt_spline.html#a3">recalc</a>(txval, tyval, size, stype &amp; Periodic);
00723         <span class="keywordflow">if</span> (rc)                         <span class="comment">// error</span>
00724         {
00725             <a class="code" href="class_qwt_curve.html#b4">drawLines</a>(painter, xMap, yMap, 0, size - 1);
00726         }
00727         <span class="keywordflow">else</span>                            <span class="comment">// Spline OK</span>
00728         {
00729             <span class="keywordtype">double</span> xmin = qwtGetMin(txval, size);
00730             <span class="keywordtype">double</span> xmax = qwtGetMax(txval, size);
00731             <span class="keywordtype">double</span> delta = (xmax - xmin) / double(d_splineSize - 1);
00732 
00733             <span class="keywordflow">for</span> (i=0;i&lt;d_splineSize;i++)
00734             {
00735                 <span class="keywordtype">double</span> dtmp = xmin + delta * double(i);
00736                 polyline.setPoint(i, <span class="keywordtype">int</span>(floor (dtmp + 0.5)),
00737                               <span class="keywordtype">int</span>(floor(d_spy.<a class="code" href="class_qwt_spline.html#a2">value</a>(dtmp) + 0.5)));
00738             }
00739         }
00740     }
00741 
00742     <span class="keyword">delete</span>[] txval;
00743     <span class="keyword">delete</span>[] tyval;
00744 
00745     <a class="code" href="class_qwt_painter.html#e19">QwtPainter::drawPolyline</a>(painter, polyline);
00746 
00747     <span class="keywordflow">if</span> ( painter-&gt;brush().style() != Qt::NoBrush )
00748     {
00749         <a class="code" href="class_qwt_curve.html#b9">closePolyline</a>(xMap, yMap, polyline);
00750         painter-&gt;setPen(QPen(Qt::NoPen));
00751         <a class="code" href="class_qwt_painter.html#e18">QwtPainter::drawPolygon</a>(painter, polyline);
00752     }
00753 }
00754 
<a name="l00785"></a><a class="code" href="class_qwt_curve.html#a17">00785</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#a17">QwtCurve::setOptions</a>(<span class="keywordtype">int</span> opt)
00786 {
00787     d_options = opt;
00788     <a class="code" href="class_qwt_curve.html#b10">curveChanged</a>();
00789 }
00790 
<a name="l00795"></a><a class="code" href="class_qwt_curve.html#a18">00795</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_curve.html#a18">QwtCurve::options</a>()<span class="keyword"> const </span>
00796 <span class="keyword"></span>{ 
00797     <span class="keywordflow">return</span> d_options; 
00798 }
00799 
<a name="l00805"></a><a class="code" href="class_qwt_curve.html#a31">00805</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#a31">QwtCurve::setSplineSize</a>(<span class="keywordtype">int</span> s)
00806 {
00807     d_splineSize = qwtMax(s, 10);
00808     <a class="code" href="class_qwt_curve.html#b10">curveChanged</a>();
00809 }
00810 
<a name="l00817"></a><a class="code" href="class_qwt_curve.html#a32">00817</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_curve.html#a32">QwtCurve::splineSize</a>()<span class="keyword"> const </span>
00818 <span class="keyword"></span>{ 
00819     <span class="keywordflow">return</span> d_splineSize; 
00820 }
00821 
<a name="l00831"></a><a class="code" href="class_qwt_curve.html#b9">00831</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#b9">QwtCurve::closePolyline</a>(<span class="keyword">const</span> <a class="code" href="class_qwt_di_map.html">QwtDiMap</a> &amp;xMap, <span class="keyword">const</span> <a class="code" href="class_qwt_di_map.html">QwtDiMap</a> &amp;yMap,
00832     QPointArray &amp;pa)<span class="keyword"> const</span>
00833 <span class="keyword"></span>{
00834     <span class="keyword">const</span> <span class="keywordtype">int</span> sz = pa.size();
00835     <span class="keywordflow">if</span> ( sz &lt; 2 )
00836         <span class="keywordflow">return</span>;
00837 
00838     pa.resize(sz + 2);
00839 
00840     <span class="keywordflow">if</span> ( d_options &amp; QwtCurve::Xfy )
00841     {
00842         pa.setPoint(sz,
00843             xMap.<a class="code" href="class_qwt_di_map.html#a7">transform</a>(d_ref), pa.point(sz - 1).y());
00844         pa.setPoint(sz + 1,
00845             xMap.<a class="code" href="class_qwt_di_map.html#a7">transform</a>(d_ref), pa.point(0).y());
00846     }
00847     <span class="keywordflow">else</span>
00848     {
00849         pa.setPoint(sz,
00850             pa.point(sz - 1).x(), yMap.<a class="code" href="class_qwt_di_map.html#a7">transform</a>(d_ref));
00851         pa.setPoint(pa.size() - 1,
00852             pa.point(0).x(), yMap.<a class="code" href="class_qwt_di_map.html#a7">transform</a>(d_ref));
00853     }
00854 }
00855 
<a name="l00865"></a><a class="code" href="class_qwt_curve.html#b3">00865</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#b3">QwtCurve::drawSymbols</a>(QPainter *painter, <a class="code" href="class_qwt_symbol.html">QwtSymbol</a> &amp;symbol,
00866     <span class="keyword">const</span> <a class="code" href="class_qwt_di_map.html">QwtDiMap</a> &amp;xMap, <span class="keyword">const</span> <a class="code" href="class_qwt_di_map.html">QwtDiMap</a> &amp;yMap, <span class="keywordtype">int</span> from, <span class="keywordtype">int</span> to)
00867 {
00868     painter-&gt;setBrush(symbol.<a class="code" href="class_qwt_symbol.html#a10">brush</a>());
00869     painter-&gt;setPen(symbol.<a class="code" href="class_qwt_symbol.html#a11">pen</a>());
00870 
00871     QRect rect;
00872     rect.setSize(QwtPainter::metricsMap().screenToLayout(symbol.<a class="code" href="class_qwt_symbol.html#a12">size</a>()));
00873 
00874     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = from; i &lt;= to; i++)
00875     {
00876         <span class="keyword">const</span> <span class="keywordtype">int</span> xi = xMap.<a class="code" href="class_qwt_di_map.html#a7">transform</a>(<a class="code" href="class_qwt_curve.html#a10">x</a>(i));
00877         <span class="keyword">const</span> <span class="keywordtype">int</span> yi = yMap.<a class="code" href="class_qwt_di_map.html#a7">transform</a>(<a class="code" href="class_qwt_curve.html#a11">y</a>(i));
00878 
00879         rect.moveCenter(QPoint(xi, yi));
00880         symbol.<a class="code" href="class_qwt_symbol.html#a14">draw</a>(painter, rect);
00881     }
00882 }
00883 
<a name="l00897"></a><a class="code" href="class_qwt_curve.html#a25">00897</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#a25">QwtCurve::setBaseline</a>(<span class="keywordtype">double</span> ref)
00898 {
00899     d_ref = ref;
00900     <a class="code" href="class_qwt_curve.html#b10">curveChanged</a>();
00901 }
00902 
<a name="l00907"></a><a class="code" href="class_qwt_curve.html#a26">00907</a> <span class="keywordtype">double</span> <a class="code" href="class_qwt_curve.html#a26">QwtCurve::baseline</a>()<span class="keyword"> const </span>
00908 <span class="keyword"></span>{ 
00909     <span class="keywordflow">return</span> d_ref; 
00910 }
00911 
<a name="l00915"></a><a class="code" href="class_qwt_curve.html#a9">00915</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_curve.html#a9">QwtCurve::dataSize</a>()<span class="keyword"> const</span>
00916 <span class="keyword"></span>{
00917     <span class="keywordflow">return</span> d_data-&gt;<a class="code" href="class_qwt_data.html#a3">size</a>();
00918 }
00919 
<a name="l00927"></a><a class="code" href="class_qwt_curve.html#b10">00927</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_curve.html#b10">QwtCurve::curveChanged</a>() 
00928 {
00929 }
</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>