File: qwt__thermo_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 (593 lines) | stat: -rw-r--r-- 33,559 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
<!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_thermo.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_thermo.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 &lt;qevent.h&gt;</span>
00012 <span class="preprocessor">#include &lt;qstyle.h&gt;</span>
00013 <span class="preprocessor">#include &lt;qpixmap.h&gt;</span>
00014 <span class="preprocessor">#include &lt;qdrawutil.h&gt;</span>
00015 <span class="preprocessor">#include "<a class="code" href="qwt__math_8h.html">qwt_math.h</a>"</span>
00016 <span class="preprocessor">#include "qwt_paint_buffer.h"</span>
00017 <span class="preprocessor">#include "qwt_thermo.h"</span>
00018 
<a name="l00020"></a><a class="code" href="class_qwt_thermo.html#a0">00020</a> <a class="code" href="class_qwt_thermo.html#a0">QwtThermo::QwtThermo</a>(QWidget *parent, <span class="keyword">const</span> <span class="keywordtype">char</span> *name): 
00021     QWidget(parent, name, Qt::WRepaintNoErase|Qt::WResizeNoErase)
00022 {
00023     init();
00024 }
00025 
<a name="l00027"></a><a class="code" href="class_qwt_thermo.html#a1">00027</a> <a class="code" href="class_qwt_thermo.html#a1">QwtThermo::~QwtThermo</a>()
00028 {
00029 }
00030 
00032 <span class="keywordtype">void</span> QwtThermo::init()
00033 {
00034     <span class="comment">// initialize data members</span>
00035     d_orient = Qt::Vertical;
00036     d_scalePos = Left;
00037     d_scaleDist = 3;
00038     d_thermoWidth = 10;
00039     d_borderWidth = 2;
00040     d_maxValue = 1.0;
00041     d_minValue = 0.0;
00042     d_value = 0.0;
00043     d_alarmLevel = 0.0;
00044     d_alarmEnabled = 0;
00045 
00046     <span class="comment">// initialize brushes;</span>
00047     d_fillBrush = QBrush(Qt::black);
00048     d_alarmBrush = QBrush(Qt::white);
00049 
00050     <span class="comment">// initialize scales</span>
00051     d_map.<a class="code" href="class_qwt_di_map.html#a6">setDblRange</a>(d_minValue, d_maxValue);
00052     <a class="code" href="class_qwt_scale_if.html#a11">scaleDraw</a>()-&gt;<a class="code" href="class_qwt_scale_draw.html#a2">setScale</a>(d_minValue, d_maxValue,
00053         <a class="code" href="class_qwt_scale_if.html#a9">scaleMaxMajor</a>(), <a class="code" href="class_qwt_scale_if.html#a8">scaleMaxMinor</a>());
00054 }
00055 
00056 
<a name="l00058"></a><a class="code" href="class_qwt_thermo.html#i0">00058</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#i0">QwtThermo::setValue</a>(<span class="keywordtype">double</span> v)
00059 {
00060     <span class="keywordflow">if</span> (d_value != v)
00061     {
00062         d_value = v;
00063         update();
00064     }
00065 }
00066 
<a name="l00068"></a><a class="code" href="class_qwt_thermo.html#b5">00068</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#b5">QwtThermo::paintEvent</a>(QPaintEvent *e)
00069 {
00070     <span class="comment">// Use double-buffering</span>
00071     <span class="keyword">const</span> QRect &amp;ur = e-&gt;rect();
00072     <span class="keywordflow">if</span> ( ur.isValid() )
00073     {
00074         <a class="code" href="class_qwt_paint_buffer.html">QwtPaintBuffer</a> paintBuffer(<span class="keyword">this</span>, ur);
00075         <a class="code" href="class_qwt_thermo.html#b0">draw</a>(paintBuffer.<a class="code" href="class_qwt_paint_buffer.html#a5">painter</a>(), ur);
00076     }
00077 }
00078 
<a name="l00080"></a><a class="code" href="class_qwt_thermo.html#b0">00080</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#b0">QwtThermo::draw</a>(QPainter *p, <span class="keyword">const</span> QRect&amp; ur)
00081 {
00082     <span class="keywordflow">if</span> ( !d_thermoRect.contains(ur) )
00083     {
00084         <span class="keywordflow">if</span> (d_scalePos != None)
00085             <a class="code" href="class_qwt_scale_if.html#a11">scaleDraw</a>()-&gt;<a class="code" href="class_qwt_scale_draw.html#a29">draw</a>(p);
00086 
00087         qDrawShadePanel(p,
00088             d_thermoRect.x() - d_borderWidth,
00089             d_thermoRect.y() - d_borderWidth,
00090             d_thermoRect.width() + 2*d_borderWidth,
00091             d_thermoRect.height() + 2*d_borderWidth,
00092             colorGroup(), TRUE, d_borderWidth,0);
00093     }
00094     <a class="code" href="class_qwt_thermo.html#b1">drawThermo</a>(p);
00095 }
00096 
<a name="l00098"></a><a class="code" href="class_qwt_thermo.html#b6">00098</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#b6">QwtThermo::resizeEvent</a>(QResizeEvent *)
00099 {
00100     <a class="code" href="class_qwt_thermo.html#b2">layoutThermo</a>( FALSE );
00101 }
00102 
<a name="l00109"></a><a class="code" href="class_qwt_thermo.html#b2">00109</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#b2">QwtThermo::layoutThermo</a>( <span class="keywordtype">bool</span> update_geometry )
00110 {
00111     QRect r = rect();
00112     <span class="keywordtype">int</span> mbd = 0;
00113     <span class="keywordflow">if</span> ( d_scalePos != None )
00114     {
00115         <span class="keywordtype">int</span> d1, d2;
00116         <a class="code" href="class_qwt_scale_if.html#a11">scaleDraw</a>()-&gt;<a class="code" href="class_qwt_scale_draw.html#a20">minBorderDist</a>(fontMetrics(), d1, d2);
00117         mbd = QMAX(d1, d2);
00118     }
00119 
00120     <span class="keywordflow">if</span> ( d_orient == Qt::Horizontal )
00121     {
00122         <span class="keywordflow">switch</span> ( d_scalePos )
00123         {
00124             <span class="keywordflow">case</span> Top:
00125                 d_thermoRect.setRect(
00126                     r.x() + mbd + d_borderWidth,
00127                     r.y() + r.height()
00128                     - d_thermoWidth - 2*d_borderWidth,
00129                     r.width() - 2*(d_borderWidth + mbd),
00130                     d_thermoWidth);
00131                 <a class="code" href="class_qwt_scale_if.html#a11">scaleDraw</a>()-&gt;<a class="code" href="class_qwt_scale_draw.html#a6">setGeometry</a>(
00132                     d_thermoRect.x(),
00133                     d_thermoRect.y() - d_borderWidth - d_scaleDist,
00134                     d_thermoRect.width(),
00135                     QwtScaleDraw::Top);
00136                 <span class="keywordflow">break</span>;
00137 
00138             <span class="keywordflow">case</span> Bottom:
00139             <span class="keywordflow">case</span> None: <span class="comment">// like Bottom but without scale</span>
00140             <span class="keywordflow">default</span>:   <span class="comment">// inconsistent orientation and scale position</span>
00141                        <span class="comment">// Mapping between values and pixels requires</span>
00142                        <span class="comment">// initialization of the scale geometry</span>
00143                 d_thermoRect.setRect(
00144                     r.x() + mbd + d_borderWidth,
00145                     r.y() + d_borderWidth,
00146                     r.width() - 2*(d_borderWidth + mbd),
00147                     d_thermoWidth);
00148                 <a class="code" href="class_qwt_scale_if.html#a11">scaleDraw</a>()-&gt;<a class="code" href="class_qwt_scale_draw.html#a6">setGeometry</a>(
00149                     d_thermoRect.x(),
00150                     d_thermoRect.y() + d_thermoRect.height()
00151                     + d_borderWidth + d_scaleDist,
00152                     d_thermoRect.width(),
00153                     QwtScaleDraw::Bottom);
00154                 <span class="keywordflow">break</span>;
00155         }
00156         d_map.<a class="code" href="class_qwt_di_map.html#a5">setIntRange</a>(d_thermoRect.x(),
00157             d_thermoRect.x() + d_thermoRect.width() - 1);
00158     }
00159     <span class="keywordflow">else</span> <span class="comment">// Qt::Vertical</span>
00160     {
00161         <span class="keywordflow">switch</span> ( d_scalePos )
00162         {
00163             <span class="keywordflow">case</span> Right:
00164                 d_thermoRect.setRect(
00165                     r.x() + d_borderWidth,
00166                     r.y() + mbd + d_borderWidth,
00167                     d_thermoWidth,
00168                     r.height() - 2*(d_borderWidth + mbd));
00169                 <a class="code" href="class_qwt_scale_if.html#a11">scaleDraw</a>()-&gt;<a class="code" href="class_qwt_scale_draw.html#a6">setGeometry</a>(
00170                     d_thermoRect.x() + d_thermoRect.width()
00171                     + d_borderWidth + d_scaleDist,
00172                     d_thermoRect.y(),
00173                     d_thermoRect.height(),
00174                     QwtScaleDraw::Right);
00175                 <span class="keywordflow">break</span>;
00176 
00177             <span class="keywordflow">case</span> Left:
00178             <span class="keywordflow">case</span> None: <span class="comment">// like Left but without scale</span>
00179             <span class="keywordflow">default</span>:   <span class="comment">// inconsistent orientation and scale position</span>
00180                        <span class="comment">// Mapping between values and pixels requires</span>
00181                        <span class="comment">// initialization of the scale geometry</span>
00182                 d_thermoRect.setRect(
00183                     r.x() + r.width() - 2*d_borderWidth - d_thermoWidth,
00184                     r.y() + mbd + d_borderWidth,
00185                     d_thermoWidth,
00186                     r.height() - 2*(d_borderWidth + mbd));
00187                 <a class="code" href="class_qwt_scale_if.html#a11">scaleDraw</a>()-&gt;<a class="code" href="class_qwt_scale_draw.html#a6">setGeometry</a>(
00188                     d_thermoRect.x() - d_scaleDist - d_borderWidth,
00189                     d_thermoRect.y(),
00190                     d_thermoRect.height(),
00191                     QwtScaleDraw::Left);
00192                 <span class="keywordflow">break</span>;
00193         }
00194         d_map.<a class="code" href="class_qwt_di_map.html#a5">setIntRange</a>(d_thermoRect.y() + d_thermoRect.height() - 1,
00195             d_thermoRect.y());
00196     }
00197     <span class="keywordflow">if</span> ( update_geometry )
00198     {
00199         updateGeometry();
00200         update();
00201     }
00202 }
00203 
<a name="l00220"></a><a class="code" href="class_qwt_thermo.html#a2">00220</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#a2">QwtThermo::setOrientation</a>(Qt::Orientation o, ScalePos s)
00221 {
00222     <span class="keywordflow">switch</span>(o)
00223     {
00224         <span class="keywordflow">case</span> Qt::Horizontal:
00225             d_orient = Qt::Horizontal;
00226             <span class="keywordflow">if</span> ((s == None) || (s == Bottom) || (s == Top))
00227                 d_scalePos = s;
00228             <span class="keywordflow">else</span>
00229                 d_scalePos = None;
00230             <span class="keywordflow">break</span>;
00231 
00232         <span class="keywordflow">case</span> Qt::Vertical:
00233             d_orient = Qt::Vertical;
00234             <span class="keywordflow">if</span> ((s == None) || (s == Left) || (s == Right))
00235                 d_scalePos = s;
00236             <span class="keywordflow">else</span>
00237                 d_scalePos = None;
00238             <span class="keywordflow">break</span>;
00239     }
00240     <a class="code" href="class_qwt_thermo.html#b2">layoutThermo</a>();
00241 }
00242 
<a name="l00257"></a><a class="code" href="class_qwt_thermo.html#a3">00257</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#a3">QwtThermo::setScalePosition</a>(ScalePos s)
00258 {
00259     <span class="keywordflow">if</span> ((s == Bottom) || (s == Top))
00260         <a class="code" href="class_qwt_thermo.html#a2">setOrientation</a>(Qt::Horizontal, s);
00261     <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((s == Left) || (s == Right))
00262         <a class="code" href="class_qwt_thermo.html#a2">setOrientation</a>(Qt::Vertical, s);
00263     <span class="keywordflow">else</span>
00264         <a class="code" href="class_qwt_thermo.html#a2">setOrientation</a>(d_orient, None);
00265 }
00266 
<a name="l00268"></a><a class="code" href="class_qwt_thermo.html#a4">00268</a> QwtThermo::ScalePos <a class="code" href="class_qwt_thermo.html#a4">QwtThermo::scalePosition</a>()<span class="keyword"> const</span>
00269 <span class="keyword"></span>{
00270     <span class="keywordflow">return</span> d_scalePos;
00271 }
00272 
<a name="l00274"></a><a class="code" href="class_qwt_thermo.html#b4">00274</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#b4">QwtThermo::fontChange</a>(<span class="keyword">const</span> QFont &amp;f)
00275 {
00276     QWidget::fontChange( f );
00277     <a class="code" href="class_qwt_thermo.html#b2">layoutThermo</a>();
00278 }
00279 
<a name="l00281"></a><a class="code" href="class_qwt_thermo.html#b3">00281</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#b3">QwtThermo::scaleChange</a>()
00282 {
00283     update();
00284     <a class="code" href="class_qwt_thermo.html#b2">layoutThermo</a>();
00285 }
00286 
<a name="l00288"></a><a class="code" href="class_qwt_thermo.html#b1">00288</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#b1">QwtThermo::drawThermo</a>(QPainter *p)
00289 {
00290     <span class="keywordtype">int</span> alarm  = 0, taval = 0;
00291 
00292     QRect fRect;
00293     QRect aRect;
00294     QRect bRect;
00295 
00296     <span class="keywordtype">int</span> inverted = ( d_maxValue &lt; d_minValue );
00297 
00298     <span class="comment">//</span>
00299     <span class="comment">//  Determine if value exceeds alarm threshold.</span>
00300     <span class="comment">//  Note: The alarm value is allowed to lie</span>
00301     <span class="comment">//        outside the interval (minValue, maxValue).</span>
00302     <span class="comment">//</span>
00303     <span class="keywordflow">if</span> (d_alarmEnabled)
00304     {
00305         <span class="keywordflow">if</span> (inverted)
00306         {
00307             alarm = ((d_alarmLevel &gt;= d_maxValue)
00308                  &amp;&amp; (d_alarmLevel &lt;= d_minValue)
00309                  &amp;&amp; (d_value &gt;= d_alarmLevel));
00310         
00311         }
00312         <span class="keywordflow">else</span>
00313         {
00314             alarm = (( d_alarmLevel &gt;= d_minValue)
00315                  &amp;&amp; (d_alarmLevel &lt;= d_maxValue)
00316                  &amp;&amp; (d_value &gt;= d_alarmLevel));
00317         }
00318     }
00319 
00320     <span class="comment">//</span>
00321     <span class="comment">//  transform values</span>
00322     <span class="comment">//</span>
00323     <span class="keywordtype">int</span> tval = d_map.<a class="code" href="class_qwt_di_map.html#a9">limTransform</a>(d_value);
00324 
00325     <span class="keywordflow">if</span> (alarm)
00326        taval = d_map.<a class="code" href="class_qwt_di_map.html#a9">limTransform</a>(d_alarmLevel);
00327 
00328     <span class="comment">//</span>
00329     <span class="comment">//  calculate recangles</span>
00330     <span class="comment">//</span>
00331     <span class="keywordflow">if</span> ( d_orient == Qt::Horizontal )
00332     {
00333         <span class="keywordflow">if</span> (inverted)
00334         {
00335             bRect.setRect(d_thermoRect.x(), d_thermoRect.y(),
00336                   tval - d_thermoRect.x(),
00337                   d_thermoRect.height());
00338         
00339             <span class="keywordflow">if</span> (alarm)
00340             {
00341                 aRect.setRect(tval, d_thermoRect.y(),
00342                       taval - tval + 1,
00343                       d_thermoRect.height());
00344                 fRect.setRect(taval + 1, d_thermoRect.y(),
00345                       d_thermoRect.x() + d_thermoRect.width() - (taval + 1),
00346                       d_thermoRect.height());
00347             }
00348             <span class="keywordflow">else</span>
00349             {
00350                 fRect.setRect(tval, d_thermoRect.y(),
00351                       d_thermoRect.x() + d_thermoRect.width() - tval,
00352                       d_thermoRect.height());
00353             }
00354         }
00355         <span class="keywordflow">else</span>
00356         {
00357             bRect.setRect(tval + 1, d_thermoRect.y(),
00358                   d_thermoRect.width() - (tval + 1 - d_thermoRect.x()),
00359                   d_thermoRect.height());
00360         
00361             <span class="keywordflow">if</span> (alarm)
00362             {
00363                 aRect.setRect(taval, d_thermoRect.y(),
00364                       tval - taval + 1,
00365                       d_thermoRect.height());
00366                 fRect.setRect(d_thermoRect.x(), d_thermoRect.y(),
00367                       taval - d_thermoRect.x(),
00368                       d_thermoRect.height());
00369             }
00370             <span class="keywordflow">else</span>
00371             {
00372                 fRect.setRect(d_thermoRect.x(), d_thermoRect.y(),
00373                       tval - d_thermoRect.x() + 1,
00374                       d_thermoRect.height());
00375             }
00376         
00377         }
00378     }
00379     <span class="keywordflow">else</span> <span class="comment">// Qt::Vertical</span>
00380     {
00381         <span class="keywordflow">if</span> (tval &lt; d_thermoRect.y())
00382             tval = d_thermoRect.y();
00383         <span class="keywordflow">else</span> 
00384         {
00385             <span class="keywordflow">if</span> (tval &gt; d_thermoRect.y() + d_thermoRect.height())
00386                 tval = d_thermoRect.y() + d_thermoRect.height();
00387         }
00388 
00389         <span class="keywordflow">if</span> (inverted)
00390         {
00391             bRect.setRect(d_thermoRect.x(), tval + 1,
00392             d_thermoRect.width(),
00393             d_thermoRect.height() - (tval + 1 - d_thermoRect.y()));
00394 
00395             <span class="keywordflow">if</span> (alarm)
00396             {
00397                 aRect.setRect(d_thermoRect.x(), taval,
00398                     d_thermoRect.width(),
00399                     tval - taval + 1);
00400                 fRect.setRect(d_thermoRect.x(), d_thermoRect.y(),
00401                     d_thermoRect.width(),
00402                 taval - d_thermoRect.y());
00403             }
00404             <span class="keywordflow">else</span>
00405             {
00406                 fRect.setRect(d_thermoRect.x(), d_thermoRect.y(),
00407                     d_thermoRect.width(),
00408                     tval - d_thermoRect.y() + 1);
00409             }
00410         }
00411         <span class="keywordflow">else</span>
00412         {
00413             bRect.setRect(d_thermoRect.x(), d_thermoRect.y(),
00414             d_thermoRect.width(),
00415             tval - d_thermoRect.y());
00416             <span class="keywordflow">if</span> (alarm)
00417             {
00418                 aRect.setRect(d_thermoRect.x(),tval,
00419                     d_thermoRect.width(),
00420                     taval - tval + 1);
00421                 fRect.setRect(d_thermoRect.x(),taval + 1,
00422                     d_thermoRect.width(),
00423                     d_thermoRect.y() + d_thermoRect.height() - (taval + 1));
00424             }
00425             <span class="keywordflow">else</span>
00426             {
00427                 fRect.setRect(d_thermoRect.x(),tval,
00428                     d_thermoRect.width(),
00429                 d_thermoRect.y() + d_thermoRect.height() - tval);
00430             }
00431         }
00432     }
00433 
00434     <span class="comment">//</span>
00435     <span class="comment">// paint thermometer</span>
00436     <span class="comment">//</span>
00437     p-&gt;fillRect(bRect, colorGroup().color(QColorGroup::Background));
00438 
00439     <span class="keywordflow">if</span> (alarm)
00440        p-&gt;fillRect(aRect, d_alarmBrush);
00441 
00442     p-&gt;fillRect(fRect, d_fillBrush);
00443 }
00444 
<a name="l00446"></a><a class="code" href="class_qwt_thermo.html#a5">00446</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#a5">QwtThermo::setBorderWidth</a>(<span class="keywordtype">int</span> w)
00447 {
00448     <span class="keywordflow">if</span> ((w &gt;= 0) &amp;&amp; (w &lt; (qwtMin(d_thermoRect.width(), 
00449         d_thermoRect.height()) + d_borderWidth) / 2  - 1))
00450     {
00451         d_borderWidth = w;
00452         <a class="code" href="class_qwt_thermo.html#b2">layoutThermo</a>();
00453     }
00454 }
00455 
<a name="l00457"></a><a class="code" href="class_qwt_thermo.html#a6">00457</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_thermo.html#a6">QwtThermo::borderWidth</a>()<span class="keyword"> const</span>
00458 <span class="keyword"></span>{
00459     <span class="keywordflow">return</span> d_borderWidth;
00460 }
00461 
<a name="l00468"></a><a class="code" href="class_qwt_thermo.html#a26">00468</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#a26">QwtThermo::setRange</a>(<span class="keywordtype">double</span> vmin, <span class="keywordtype">double</span> vmax, <span class="keywordtype">bool</span> logarithmic)
00469 {
00470     d_minValue = vmin;
00471     d_maxValue = vmax;
00472 
00473     d_map.<a class="code" href="class_qwt_di_map.html#a6">setDblRange</a>(d_minValue, d_maxValue, logarithmic);
00474     <span class="keywordflow">if</span> (!<a class="code" href="class_qwt_scale_if.html#b0">hasUserScale</a>())
00475     {
00476         <a class="code" href="class_qwt_scale_div.html">QwtScaleDiv</a> oldscl(<a class="code" href="class_qwt_scale_if.html#a11">scaleDraw</a>()-&gt;scaleDiv());
00477 
00478         <a class="code" href="class_qwt_scale_if.html#a11">scaleDraw</a>()-&gt;<a class="code" href="class_qwt_scale_draw.html#a2">setScale</a>(d_minValue, d_maxValue,
00479             <a class="code" href="class_qwt_scale_if.html#a9">scaleMaxMajor</a>(), <a class="code" href="class_qwt_scale_if.html#a8">scaleMaxMinor</a>(), 0.0, logarithmic);
00480         <span class="keywordflow">if</span> (oldscl != <a class="code" href="class_qwt_scale_if.html#a11">scaleDraw</a>()-&gt;<a class="code" href="class_qwt_scale_draw.html#a17">scaleDiv</a>())
00481             <a class="code" href="class_qwt_thermo.html#b3">scaleChange</a>();
00482     }
00483     <a class="code" href="class_qwt_thermo.html#b2">layoutThermo</a>();
00484 }
00485 
<a name="l00490"></a><a class="code" href="class_qwt_thermo.html#a7">00490</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#a7">QwtThermo::setFillBrush</a>(<span class="keyword">const</span> QBrush&amp; b)
00491 {
00492     d_fillBrush = b;
00493     update();
00494 }
00495 
<a name="l00497"></a><a class="code" href="class_qwt_thermo.html#a8">00497</a> <span class="keyword">const</span> QBrush&amp; <a class="code" href="class_qwt_thermo.html#a8">QwtThermo::fillBrush</a>()<span class="keyword"> const</span>
00498 <span class="keyword"></span>{
00499     <span class="keywordflow">return</span> d_fillBrush;
00500 }
00501 
<a name="l00506"></a><a class="code" href="class_qwt_thermo.html#a9">00506</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#a9">QwtThermo::setFillColor</a>(<span class="keyword">const</span> QColor &amp;c)
00507 {
00508     d_fillBrush.setColor(c);
00509     update();
00510 }
00511 
<a name="l00513"></a><a class="code" href="class_qwt_thermo.html#a10">00513</a> <span class="keyword">const</span> QColor &amp;<a class="code" href="class_qwt_thermo.html#a10">QwtThermo::fillColor</a>()<span class="keyword"> const</span>
00514 <span class="keyword"></span>{
00515     <span class="keywordflow">return</span> d_fillBrush.color();
00516 }
00517 
<a name="l00522"></a><a class="code" href="class_qwt_thermo.html#a11">00522</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#a11">QwtThermo::setAlarmBrush</a>(<span class="keyword">const</span> QBrush&amp; b)
00523 {
00524     d_alarmBrush = b;
00525     update();
00526 }
00527 
<a name="l00529"></a><a class="code" href="class_qwt_thermo.html#a12">00529</a> <span class="keyword">const</span> QBrush&amp; <a class="code" href="class_qwt_thermo.html#a12">QwtThermo::alarmBrush</a>()<span class="keyword"> const</span>
00530 <span class="keyword"></span>{
00531     <span class="keywordflow">return</span> d_alarmBrush;
00532 }
00533 
<a name="l00538"></a><a class="code" href="class_qwt_thermo.html#a13">00538</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#a13">QwtThermo::setAlarmColor</a>(<span class="keyword">const</span> QColor &amp;c)
00539 {
00540     d_alarmBrush.setColor(c);
00541     update();
00542 }
00543 
<a name="l00545"></a><a class="code" href="class_qwt_thermo.html#a14">00545</a> <span class="keyword">const</span> QColor &amp;<a class="code" href="class_qwt_thermo.html#a14">QwtThermo::alarmColor</a>()<span class="keyword"> const</span>
00546 <span class="keyword"></span>{
00547     <span class="keywordflow">return</span> d_alarmBrush.color();
00548 }
00549 
<a name="l00551"></a><a class="code" href="class_qwt_thermo.html#a15">00551</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#a15">QwtThermo::setAlarmLevel</a>(<span class="keywordtype">double</span> v)
00552 {
00553     d_alarmLevel = v;
00554     d_alarmEnabled = 1;
00555     update();
00556 }
00557 
<a name="l00559"></a><a class="code" href="class_qwt_thermo.html#a16">00559</a> <span class="keywordtype">double</span> <a class="code" href="class_qwt_thermo.html#a16">QwtThermo::alarmLevel</a>()<span class="keyword"> const</span>
00560 <span class="keyword"></span>{
00561     <span class="keywordflow">return</span> d_alarmLevel;
00562 }
00563 
<a name="l00565"></a><a class="code" href="class_qwt_thermo.html#a19">00565</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#a19">QwtThermo::setPipeWidth</a>(<span class="keywordtype">int</span> w)
00566 {
00567     <span class="keywordflow">if</span> (w &gt; 0)
00568     {
00569         d_thermoWidth = w;
00570         <a class="code" href="class_qwt_thermo.html#b2">layoutThermo</a>();
00571     }
00572 }
00573 
<a name="l00575"></a><a class="code" href="class_qwt_thermo.html#a20">00575</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_thermo.html#a20">QwtThermo::pipeWidth</a>()<span class="keyword"> const</span>
00576 <span class="keyword"></span>{
00577     <span class="keywordflow">return</span> d_thermoWidth;
00578 }
00579 
00580 
<a name="l00595"></a><a class="code" href="class_qwt_thermo.html#a27">00595</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#a27">QwtThermo::setMargin</a>(<span class="keywordtype">int</span>)
00596 {
00597 }
00598 
00599 
<a name="l00604"></a><a class="code" href="class_qwt_thermo.html#a17">00604</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#a17">QwtThermo::setAlarmEnabled</a>(<span class="keywordtype">bool</span> tf)
00605 {
00606     d_alarmEnabled = tf;
00607     update();
00608 }
00609 
<a name="l00611"></a><a class="code" href="class_qwt_thermo.html#a18">00611</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_thermo.html#a18">QwtThermo::alarmEnabled</a>()<span class="keyword"> const</span>
00612 <span class="keyword"></span>{
00613     <span class="keywordflow">return</span> d_alarmEnabled;
00614 }
00615 
<a name="l00621"></a><a class="code" href="class_qwt_thermo.html#a30">00621</a> QSizePolicy <a class="code" href="class_qwt_thermo.html#a30">QwtThermo::sizePolicy</a>()<span class="keyword"> const</span>
00622 <span class="keyword"></span>{
00623     QSizePolicy sp;
00624     <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_scale_if.html#a11">scaleDraw</a>()-&gt;<a class="code" href="class_qwt_scale_draw.html#a10">orientation</a>() == QwtScaleDraw::Left ||
00625         <a class="code" href="class_qwt_scale_if.html#a11">scaleDraw</a>()-&gt;<a class="code" href="class_qwt_scale_draw.html#a10">orientation</a>() == QwtScaleDraw::Right )
00626     {
00627         sp.setHorData( QSizePolicy::Fixed );
00628         sp.setVerData( QSizePolicy::MinimumExpanding );
00629     }
00630     <span class="keywordflow">else</span>
00631     {
00632         sp.setHorData( QSizePolicy::MinimumExpanding );
00633         sp.setVerData( QSizePolicy::Fixed );
00634     }
00635     <span class="keywordflow">return</span> sp;
00636 }
00637 
<a name="l00642"></a><a class="code" href="class_qwt_thermo.html#a28">00642</a> QSize <a class="code" href="class_qwt_thermo.html#a28">QwtThermo::sizeHint</a>()<span class="keyword"> const</span>
00643 <span class="keyword"></span>{
00644     <span class="keywordflow">return</span> <a class="code" href="class_qwt_thermo.html#a29">minimumSizeHint</a>();
00645 }
00646 
<a name="l00652"></a><a class="code" href="class_qwt_thermo.html#a29">00652</a> QSize <a class="code" href="class_qwt_thermo.html#a29">QwtThermo::minimumSizeHint</a>()<span class="keyword"> const</span>
00653 <span class="keyword"></span>{
00654     <span class="keywordtype">int</span> w = 0, h = 0;
00655 
00656     <span class="keywordflow">if</span> ( d_scalePos != None )
00657     {
00658         <span class="keywordtype">int</span> smw = <a class="code" href="class_qwt_scale_if.html#a11">scaleDraw</a>()-&gt;<a class="code" href="class_qwt_scale_draw.html#a23">minWidth</a>( QPen(), fontMetrics() );
00659         <span class="keywordtype">int</span> smh = <a class="code" href="class_qwt_scale_if.html#a11">scaleDraw</a>()-&gt;<a class="code" href="class_qwt_scale_draw.html#a22">minHeight</a>( QPen(), fontMetrics() );
00660 
00661         <span class="keywordflow">if</span> ( d_orient == Qt::Vertical )
00662         {
00663             w = d_thermoWidth + smw + 3 * d_borderWidth + d_scaleDist;
00664             h = smh + 2 * d_borderWidth;
00665         }
00666         <span class="keywordflow">else</span>
00667         {
00668             w = smw + 2 * d_borderWidth;
00669             h = d_thermoWidth + smh + 3 * d_borderWidth + d_scaleDist;
00670         }
00671 
00672     }
00673     <span class="keywordflow">else</span> <span class="comment">// no scale</span>
00674     {
00675         <span class="keywordflow">if</span> ( d_orient == Qt::Vertical )
00676         {
00677             w = d_thermoWidth + 2 * d_borderWidth;
00678             h = 200 + 2 * d_borderWidth;
00679         }
00680         <span class="keywordflow">else</span>
00681         {
00682             w = 200 + 2 * d_borderWidth;
00683             h = d_thermoWidth + 2 * d_borderWidth;
00684         }
00685     }
00686     <span class="keywordflow">return</span> QSize( w, h );
00687 }
00688 
00689 <span class="comment">// Local Variables:</span>
00690 <span class="comment">// mode: C++</span>
00691 <span class="comment">// c-file-style: "stroustrup"</span>
00692 <span class="comment">// indent-tabs-mode: nil</span>
00693 <span class="comment">// End:</span>
</div></pre><hr size="1"><address style="align: right;"><small>Generated on Tue Nov 16 21:12:21 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>