~ubuntu-branches/ubuntu/oneiric/qwt/oneiric-proposed

« back to all changes in this revision

Viewing changes to qwt/src/qwt_dial_needle.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Fathi Boudra
  • Date: 2011-06-10 11:22:47 UTC
  • mfrom: (1.1.6 upstream) (2.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20110610112247-0i1019vvmzaq6p86
Tags: 6.0.0-1
* New upstream release (Closes: #624107):
  - drop Qt3 support. (Closes: #604379, #626868)
* Register documentation with doc-base. (Closes: #626567)
* Drop patches:
  - 01_makefiles.diff
  - 02_add_missing_warnings.diff
  - 03_qwt_branch_pull_r544.diff
* Add qwt_install_paths.patch to fix the hardcoded installation paths.
* Update debian/control:
  - drop libqt3-mt-dev build dependency.
  - bump Standards-Version to 3.9.2 (no changes).
  - drop Qt3 related packages.
  - due to bump soname (and as we dropper Qt3 support):
    - libqwt5-qt4-dev -> libqwt-dev
    - libqwt5-qt4 -> libqwt6
    - libqwt5-doc -> libqwt-doc
* Update debian/copyright file.
* Update debian/rules: drop Qt3 packages support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2
 
 * Qwt Widget Library
3
 
 * Copyright (C) 1997   Josef Wilgen
4
 
 * Copyright (C) 2002   Uwe Rathmann
5
 
 *
6
 
 * This library is free software; you can redistribute it and/or
7
 
 * modify it under the terms of the Qwt License, Version 1.0
8
 
 *****************************************************************************/
9
 
 
10
 
#include <math.h>
11
 
#include <qapplication.h>
12
 
#include <qpainter.h>
13
 
#include "qwt_math.h"
14
 
#include "qwt_painter.h"
15
 
#include "qwt_polygon.h"
16
 
#include "qwt_dial_needle.h"
17
 
 
18
 
#if QT_VERSION < 0x040000
19
 
typedef QColorGroup QwtPalette;
20
 
#else
21
 
typedef QPalette QwtPalette;
22
 
#endif
23
 
 
24
 
//! Constructor
25
 
QwtDialNeedle::QwtDialNeedle():
26
 
    d_palette(QApplication::palette())
27
 
{
28
 
}
29
 
 
30
 
//! Destructor
31
 
QwtDialNeedle::~QwtDialNeedle() 
32
 
{
33
 
}
34
 
 
35
 
/*!
36
 
    Sets the palette for the needle.
37
 
 
38
 
    \param palette New Palette
39
 
*/
40
 
void QwtDialNeedle::setPalette(const QPalette &palette) 
41
 
42
 
    d_palette = palette; 
43
 
}
44
 
 
45
 
/*!
46
 
  \return the palette of the needle.
47
 
*/
48
 
const QPalette &QwtDialNeedle::palette() const 
49
 
50
 
    return d_palette; 
51
 
}
52
 
 
53
 
//!  Draw the knob 
54
 
void QwtDialNeedle::drawKnob(QPainter *painter,
55
 
    const QPoint &pos, int width, const QBrush &brush, bool sunken)
56
 
{
57
 
    painter->save();
58
 
 
59
 
    QRect rect(0, 0, width, width);
60
 
    rect.moveCenter(pos);
61
 
 
62
 
    painter->setPen(Qt::NoPen);
63
 
    painter->setBrush(brush);
64
 
    painter->drawEllipse(rect);
65
 
 
66
 
    painter->setBrush(Qt::NoBrush);
67
 
 
68
 
    const int colorOffset = 20;
69
 
 
70
 
    int startAngle = 45;
71
 
    if ( sunken )
72
 
        startAngle += 180;
73
 
 
74
 
    QPen pen;
75
 
    pen.setWidth(1);
76
 
 
77
 
    pen.setColor(brush.color().dark(100 - colorOffset));
78
 
    painter->setPen(pen);
79
 
    painter->drawArc(rect, startAngle * 16, 180 * 16);
80
 
 
81
 
    pen.setColor(brush.color().dark(100 + colorOffset));
82
 
    painter->setPen(pen);
83
 
    painter->drawArc(rect, (startAngle + 180) * 16, 180 * 16);
84
 
 
85
 
    painter->restore();
86
 
}
87
 
 
88
 
/*!
89
 
  Constructor
90
 
 
91
 
  \param style Style
92
 
  \param hasKnob With/Without knob
93
 
  \param mid Middle color
94
 
  \param base Base color
95
 
*/
96
 
QwtDialSimpleNeedle::QwtDialSimpleNeedle(Style style, bool hasKnob, 
97
 
        const QColor &mid, const QColor &base):
98
 
    d_style(style),
99
 
    d_hasKnob(hasKnob),
100
 
    d_width(-1)
101
 
{
102
 
    QPalette palette;
103
 
    for ( int i = 0; i < QPalette::NColorGroups; i++ )
104
 
    {
105
 
        palette.setColor((QPalette::ColorGroup)i,
106
 
            QwtPalette::Mid, mid);
107
 
        palette.setColor((QPalette::ColorGroup)i,
108
 
            QwtPalette::Base, base);
109
 
    }
110
 
 
111
 
    setPalette(palette);
112
 
}
113
 
 
114
 
/*! 
115
 
  Set the width of the needle
116
 
  \param width Width
117
 
  \sa width()
118
 
*/
119
 
void QwtDialSimpleNeedle::setWidth(int width)
120
 
{
121
 
    d_width = width;
122
 
}
123
 
 
124
 
/*!
125
 
  \return the width of the needle
126
 
  \sa setWidth()
127
 
*/
128
 
int QwtDialSimpleNeedle::width() const
129
 
{
130
 
    return d_width;
131
 
}
132
 
 
133
 
/*!
134
 
 Draw the needle
135
 
 
136
 
 \param painter Painter
137
 
 \param center Center of the dial, start position for the needle
138
 
 \param length Length of the needle
139
 
 \param direction Direction of the needle, in degrees counter clockwise
140
 
 \param colorGroup Color group, used for painting
141
 
*/
142
 
void QwtDialSimpleNeedle::draw(QPainter *painter, const QPoint &center,
143
 
    int length, double direction, QPalette::ColorGroup colorGroup) const
144
 
{
145
 
    if ( d_style == Arrow )
146
 
    {
147
 
        drawArrowNeedle(painter, palette(), colorGroup,
148
 
            center, length, d_width, direction, d_hasKnob);
149
 
    }
150
 
    else
151
 
    {
152
 
        drawRayNeedle(painter, palette(), colorGroup, 
153
 
            center, length, d_width, direction, d_hasKnob); 
154
 
    }
155
 
}
156
 
 
157
 
/*!
158
 
  Draw a needle looking like a ray
159
 
 
160
 
  \param painter Painter
161
 
  \param palette Palette
162
 
  \param colorGroup Color group
163
 
  \param center center of the needle
164
 
  \param length Length of the needle
165
 
  \param width Width of the needle
166
 
  \param direction Current Direction
167
 
  \param hasKnob With/Without knob
168
 
*/
169
 
void QwtDialSimpleNeedle::drawRayNeedle(QPainter *painter, 
170
 
    const QPalette &palette, QPalette::ColorGroup colorGroup,
171
 
    const QPoint &center, int length, int width, double direction, 
172
 
    bool hasKnob)
173
 
{
174
 
    if ( width <= 0 )
175
 
        width = 5;
176
 
 
177
 
    direction *= M_PI / 180.0;
178
 
 
179
 
    painter->save();
180
 
 
181
 
    const QPoint p1(center.x() + 1, center.y() + 2);
182
 
    const QPoint p2 = qwtPolar2Pos(p1, length, direction);
183
 
 
184
 
    if ( width == 1 )
185
 
    {
186
 
        const QColor midColor =
187
 
            palette.color(colorGroup, QwtPalette::Mid);
188
 
 
189
 
        painter->setPen(QPen(midColor, 1));
190
 
        painter->drawLine(p1, p2);
191
 
    }
192
 
    else
193
 
    {
194
 
        QwtPolygon pa(4);
195
 
        pa.setPoint(0, qwtPolar2Pos(p1, width / 2, direction + M_PI_2));
196
 
        pa.setPoint(1, qwtPolar2Pos(p2, width / 2, direction + M_PI_2));
197
 
        pa.setPoint(2, qwtPolar2Pos(p2, width / 2, direction - M_PI_2));
198
 
        pa.setPoint(3, qwtPolar2Pos(p1, width / 2, direction - M_PI_2));
199
 
 
200
 
        painter->setPen(Qt::NoPen);
201
 
        painter->setBrush(palette.brush(colorGroup, QwtPalette::Mid));
202
 
        painter->drawPolygon(pa);
203
 
    }
204
 
    if ( hasKnob )
205
 
    {
206
 
        int knobWidth = qwtMax(qRound(width * 0.7), 5);
207
 
        if ( knobWidth % 2 == 0 )
208
 
            knobWidth++;
209
 
 
210
 
        drawKnob(painter, center, knobWidth, 
211
 
            palette.brush(colorGroup, QwtPalette::Base), 
212
 
            false);
213
 
    }
214
 
 
215
 
    painter->restore();
216
 
}
217
 
 
218
 
/*!
219
 
  Draw a needle looking like an arrow
220
 
 
221
 
  \param painter Painter
222
 
  \param palette Palette
223
 
  \param colorGroup Color group
224
 
  \param center center of the needle
225
 
  \param length Length of the needle
226
 
  \param width Width of the needle
227
 
  \param direction Current Direction
228
 
  \param hasKnob With/Without knob
229
 
*/
230
 
void QwtDialSimpleNeedle::drawArrowNeedle(QPainter *painter, 
231
 
    const QPalette &palette, QPalette::ColorGroup colorGroup,
232
 
    const QPoint &center, int length, int width,
233
 
    double direction, bool hasKnob)
234
 
{
235
 
    direction *= M_PI / 180.0;
236
 
 
237
 
    painter->save();
238
 
 
239
 
    if ( width <= 0 )
240
 
    {
241
 
        width = (int)qwtMax(length * 0.06, 9.0);
242
 
        if ( width % 2 == 0 )
243
 
            width++;
244
 
    }
245
 
 
246
 
    const int peak = 3;
247
 
    const QPoint p1(center.x() + 1, center.y() + 1);
248
 
    const QPoint p2 = qwtPolar2Pos(p1, length - peak, direction);
249
 
    const QPoint p3 = qwtPolar2Pos(p1, length, direction);
250
 
 
251
 
    QwtPolygon pa(5);
252
 
    pa.setPoint(0, qwtPolar2Pos(p1, width / 2, direction - M_PI_2));
253
 
    pa.setPoint(1, qwtPolar2Pos(p2, 1, direction - M_PI_2));
254
 
    pa.setPoint(2, p3);
255
 
    pa.setPoint(3, qwtPolar2Pos(p2, 1, direction + M_PI_2));
256
 
    pa.setPoint(4, qwtPolar2Pos(p1, width / 2, direction + M_PI_2));
257
 
 
258
 
    painter->setPen(Qt::NoPen);
259
 
    painter->setBrush(palette.brush(colorGroup, QwtPalette::Mid));
260
 
    painter->drawPolygon(pa);
261
 
 
262
 
    QwtPolygon shadowPa(3);
263
 
 
264
 
    const int colorOffset = 10;
265
 
 
266
 
    int i;
267
 
    for ( i = 0; i < 3; i++ )
268
 
        shadowPa.setPoint(i, pa[i]);
269
 
 
270
 
    const QColor midColor = palette.color(colorGroup, QwtPalette::Mid);
271
 
 
272
 
    painter->setPen(midColor.dark(100 + colorOffset));
273
 
    painter->drawPolyline(shadowPa);
274
 
 
275
 
    for ( i = 0; i < 3; i++ )
276
 
        shadowPa.setPoint(i, pa[i + 2]);
277
 
 
278
 
    painter->setPen(midColor.dark(100 - colorOffset));
279
 
    painter->drawPolyline(shadowPa);
280
 
 
281
 
    if ( hasKnob )
282
 
    {
283
 
        drawKnob(painter, center, qRound(width * 1.3), 
284
 
            palette.brush(colorGroup, QwtPalette::Base),
285
 
            false);
286
 
    }
287
 
 
288
 
    painter->restore();
289
 
}
290
 
 
291
 
//! Constructor
292
 
 
293
 
QwtCompassMagnetNeedle::QwtCompassMagnetNeedle(Style style,
294
 
        const QColor &light, const QColor &dark):
295
 
    d_style(style)
296
 
{   
297
 
    QPalette palette;
298
 
    for ( int i = 0; i < QPalette::NColorGroups; i++ )
299
 
    {
300
 
        palette.setColor((QPalette::ColorGroup)i,
301
 
            QwtPalette::Light, light);
302
 
        palette.setColor((QPalette::ColorGroup)i,
303
 
            QwtPalette::Dark, dark);
304
 
        palette.setColor((QPalette::ColorGroup)i,
305
 
            QwtPalette::Base, Qt::darkGray);
306
 
    }
307
 
 
308
 
    setPalette(palette); 
309
 
}
310
 
 
311
 
/*!
312
 
    Draw the needle
313
 
 
314
 
    \param painter Painter
315
 
    \param center Center of the dial, start position for the needle
316
 
    \param length Length of the needle
317
 
    \param direction Direction of the needle, in degrees counter clockwise
318
 
    \param colorGroup Color group, used for painting
319
 
*/
320
 
void QwtCompassMagnetNeedle::draw(QPainter *painter, const QPoint &center,
321
 
    int length, double direction, QPalette::ColorGroup colorGroup) const
322
 
{
323
 
    if ( d_style == ThinStyle )
324
 
    {
325
 
        drawThinNeedle(painter, palette(), colorGroup, 
326
 
            center, length, direction); 
327
 
    }
328
 
    else
329
 
    {
330
 
        drawTriangleNeedle(painter, palette(), colorGroup,
331
 
            center, length, direction);
332
 
    }
333
 
}
334
 
 
335
 
/*!
336
 
  Draw a compass needle 
337
 
 
338
 
  \param painter Painter
339
 
  \param palette Palette
340
 
  \param colorGroup Color group
341
 
  \param center Center, where the needle starts
342
 
  \param length Length of the needle
343
 
  \param direction Direction
344
 
*/
345
 
void QwtCompassMagnetNeedle::drawTriangleNeedle(QPainter *painter, 
346
 
    const QPalette &palette, QPalette::ColorGroup colorGroup,
347
 
    const QPoint &center, int length, double direction) 
348
 
{
349
 
    const QBrush darkBrush = palette.brush(colorGroup, QwtPalette::Dark);
350
 
    const QBrush lightBrush = palette.brush(colorGroup, QwtPalette::Light);
351
 
 
352
 
    QBrush brush;
353
 
 
354
 
    const int width = qRound(length / 3.0);
355
 
    const int colorOffset =  10;
356
 
 
357
 
    painter->save();
358
 
    painter->setPen(Qt::NoPen);
359
 
 
360
 
    const QPoint arrowCenter(center.x() + 1, center.y() + 1);
361
 
 
362
 
    QwtPolygon pa(3);
363
 
    pa.setPoint(0, arrowCenter);
364
 
    pa.setPoint(1, qwtDegree2Pos(arrowCenter, length, direction));
365
 
 
366
 
    pa.setPoint(2, qwtDegree2Pos(arrowCenter, width / 2, direction + 90.0));
367
 
 
368
 
    brush = darkBrush;
369
 
    brush.setColor(brush.color().dark(100 + colorOffset));
370
 
    painter->setBrush(brush);
371
 
    painter->drawPolygon(pa);
372
 
 
373
 
    pa.setPoint(2, qwtDegree2Pos(arrowCenter, width / 2, direction - 90.0));
374
 
 
375
 
    brush = darkBrush;
376
 
    brush.setColor(brush.color().dark(100 - colorOffset));
377
 
    painter->setBrush(brush);
378
 
    painter->drawPolygon(pa);
379
 
 
380
 
    // --
381
 
 
382
 
    pa.setPoint(1, qwtDegree2Pos(arrowCenter, length, direction + 180.0));
383
 
 
384
 
    pa.setPoint(2, qwtDegree2Pos(arrowCenter, width / 2, direction + 90.0));
385
 
 
386
 
    brush = lightBrush;
387
 
    brush.setColor(brush.color().dark(100 + colorOffset));
388
 
    painter->setBrush(brush);
389
 
    painter->drawPolygon(pa);
390
 
 
391
 
    pa.setPoint(2, qwtDegree2Pos(arrowCenter, width / 2, direction - 90.0));
392
 
 
393
 
    brush = lightBrush;
394
 
    brush.setColor(brush.color().dark(100 - colorOffset));
395
 
    painter->setBrush(brush);
396
 
    painter->drawPolygon(pa);
397
 
 
398
 
    painter->restore();
399
 
}
400
 
 
401
 
/*!
402
 
  Draw a compass needle 
403
 
 
404
 
  \param painter Painter
405
 
  \param palette Palette
406
 
  \param colorGroup Color group
407
 
  \param center Center, where the needle starts
408
 
  \param length Length of the needle
409
 
  \param direction Direction
410
 
*/
411
 
void QwtCompassMagnetNeedle::drawThinNeedle(QPainter *painter, 
412
 
    const QPalette &palette, QPalette::ColorGroup colorGroup,
413
 
    const QPoint &center, int length, double direction) 
414
 
{
415
 
    const QBrush darkBrush = palette.brush(colorGroup, QwtPalette::Dark);
416
 
    const QBrush lightBrush = palette.brush(colorGroup, QwtPalette::Light);
417
 
    const QBrush baseBrush = palette.brush(colorGroup, QwtPalette::Base);
418
 
 
419
 
    const int colorOffset = 10;
420
 
    const int width = qwtMax(qRound(length / 6.0), 3);
421
 
 
422
 
    painter->save();
423
 
 
424
 
    const QPoint arrowCenter(center.x() + 1, center.y() + 1);
425
 
 
426
 
    drawPointer(painter, darkBrush, colorOffset, 
427
 
        arrowCenter, length, width, direction);
428
 
    drawPointer(painter, lightBrush, -colorOffset, 
429
 
        arrowCenter, length, width, direction + 180.0);
430
 
    
431
 
    drawKnob(painter, arrowCenter, width, baseBrush, true);
432
 
 
433
 
    painter->restore();
434
 
}
435
 
 
436
 
/*!
437
 
  Draw a compass needle 
438
 
 
439
 
  \param painter Painter
440
 
  \param brush Brush
441
 
  \param colorOffset Color offset
442
 
  \param center Center, where the needle starts
443
 
  \param length Length of the needle
444
 
  \param width Width of the needle
445
 
  \param direction Direction
446
 
*/
447
 
void QwtCompassMagnetNeedle::drawPointer(
448
 
    QPainter *painter, const QBrush &brush,
449
 
    int colorOffset, const QPoint &center, int length, 
450
 
    int width, double direction)
451
 
{
452
 
    painter->save();
453
 
 
454
 
    const int peak = qwtMax(qRound(length / 10.0), 5);
455
 
 
456
 
    const int knobWidth = width + 8;
457
 
    QRect knobRect(0, 0, knobWidth, knobWidth);
458
 
    knobRect.moveCenter(center);
459
 
 
460
 
    QwtPolygon pa(5);
461
 
 
462
 
    pa.setPoint(0, qwtDegree2Pos(center, width / 2, direction + 90.0));
463
 
    pa.setPoint(1, center);
464
 
    pa.setPoint(2, qwtDegree2Pos(pa.point(1), length - peak, direction));
465
 
    pa.setPoint(3, qwtDegree2Pos(center, length, direction));
466
 
    pa.setPoint(4, qwtDegree2Pos(pa.point(0), length - peak, direction));
467
 
 
468
 
    painter->setPen(Qt::NoPen);
469
 
 
470
 
    QBrush darkBrush = brush;
471
 
    darkBrush.setColor(darkBrush.color().dark(100 + colorOffset));
472
 
    painter->setBrush(darkBrush);
473
 
    painter->drawPolygon(pa);
474
 
    painter->drawPie(knobRect, qRound(direction * 16), 90 * 16);
475
 
 
476
 
    pa.setPoint(0, qwtDegree2Pos(center, width / 2, direction - 90.0));
477
 
    pa.setPoint(4, qwtDegree2Pos(pa.point(0), length - peak, direction));
478
 
 
479
 
    QBrush lightBrush = brush;
480
 
    lightBrush.setColor(lightBrush.color().dark(100 - colorOffset));
481
 
    painter->setBrush(lightBrush);
482
 
    painter->drawPolygon(pa);
483
 
    painter->drawPie(knobRect, qRound(direction * 16), -90 * 16);
484
 
 
485
 
    painter->restore();
486
 
}
487
 
 
488
 
/*! 
489
 
   Constructor
490
 
 
491
 
   \param style Arrow style
492
 
   \param light Light color
493
 
   \param dark Dark color
494
 
*/
495
 
QwtCompassWindArrow::QwtCompassWindArrow(Style style, 
496
 
        const QColor &light, const QColor &dark):
497
 
    d_style(style)
498
 
{
499
 
    QPalette palette;
500
 
    for ( int i = 0; i < QPalette::NColorGroups; i++ )
501
 
    {
502
 
        palette.setColor((QPalette::ColorGroup)i,
503
 
            QwtPalette::Light, light);
504
 
        palette.setColor((QPalette::ColorGroup)i,
505
 
            QwtPalette::Dark, dark);
506
 
    }
507
 
 
508
 
    setPalette(palette);
509
 
}
510
 
 
511
 
/*!
512
 
 Draw the needle
513
 
 
514
 
 \param painter Painter
515
 
 \param center Center of the dial, start position for the needle
516
 
 \param length Length of the needle
517
 
 \param direction Direction of the needle, in degrees counter clockwise
518
 
 \param colorGroup Color group, used for painting
519
 
*/
520
 
void QwtCompassWindArrow::draw(QPainter *painter, const QPoint &center,
521
 
    int length, double direction, QPalette::ColorGroup colorGroup) const
522
 
{
523
 
    if ( d_style == Style1 )
524
 
    {
525
 
        drawStyle1Needle(painter, palette(), colorGroup,
526
 
            center, length, direction);
527
 
    }
528
 
    else
529
 
    {
530
 
        drawStyle2Needle(painter, palette(), colorGroup,
531
 
            center, length, direction); 
532
 
    }
533
 
}
534
 
 
535
 
/*!
536
 
  Draw a compass needle 
537
 
 
538
 
 \param painter Painter
539
 
 \param palette Palette
540
 
 \param colorGroup colorGroup
541
 
 \param center Center of the dial, start position for the needle
542
 
 \param length Length of the needle
543
 
 \param direction Direction of the needle, in degrees counter clockwise
544
 
*/
545
 
void QwtCompassWindArrow::drawStyle1Needle(QPainter *painter, 
546
 
    const QPalette &palette, QPalette::ColorGroup colorGroup,
547
 
    const QPoint &center, int length, double direction) 
548
 
{
549
 
    const QBrush lightBrush = palette.brush(colorGroup, QwtPalette::Light);
550
 
 
551
 
    const double AR1[] = {0, 0.4, 0.3, 1, 0.8, 1, 0.3, 0.4};
552
 
    const double AW1[] = {0, -45, -20, -15, 0, 15, 20, 45};
553
 
 
554
 
    const QPoint arrowCenter(center.x() + 1, center.y() + 1);
555
 
 
556
 
    QwtPolygon pa(8);
557
 
    pa.setPoint(0, arrowCenter);
558
 
    for (int i=1; i<8; i++) 
559
 
    {
560
 
        const QPoint p = qwtDegree2Pos(center, 
561
 
            AR1[i] * length, direction + AW1[i]);
562
 
        pa.setPoint(i, p);
563
 
    }
564
 
 
565
 
    painter->save();
566
 
    painter->setPen(Qt::NoPen);
567
 
    painter->setBrush(lightBrush);
568
 
    painter->drawPolygon(pa);
569
 
    painter->restore();
570
 
}
571
 
 
572
 
/*!
573
 
  Draw a compass needle 
574
 
 
575
 
 \param painter Painter
576
 
 \param palette Palette
577
 
 \param colorGroup colorGroup
578
 
 \param center Center of the dial, start position for the needle
579
 
 \param length Length of the needle
580
 
 \param direction Direction of the needle, in degrees counter clockwise
581
 
*/
582
 
void QwtCompassWindArrow::drawStyle2Needle(QPainter *painter, 
583
 
    const QPalette &palette, QPalette::ColorGroup colorGroup,
584
 
    const QPoint &center, int length, double direction) 
585
 
{
586
 
    const QBrush lightBrush = palette.brush(colorGroup, QwtPalette::Light);
587
 
    const QBrush darkBrush = palette.brush(colorGroup, QwtPalette::Dark);
588
 
 
589
 
    painter->save();
590
 
    painter->setPen(Qt::NoPen);
591
 
 
592
 
    const double angle = 12.0;
593
 
    const double ratio = 0.7;
594
 
 
595
 
    const QPoint arrowCenter(center.x() + 1, center.y() + 1);
596
 
 
597
 
    QwtPolygon pa(3);
598
 
 
599
 
    pa.setPoint(0, center);
600
 
    pa.setPoint(2, qwtDegree2Pos(arrowCenter, ratio * length, direction));
601
 
 
602
 
    pa.setPoint(1, qwtDegree2Pos(arrowCenter, length, direction + angle));
603
 
    painter->setBrush(darkBrush);
604
 
    painter->drawPolygon(pa);
605
 
 
606
 
    pa.setPoint(1, qwtDegree2Pos(arrowCenter, length, direction - angle));
607
 
    painter->setBrush(lightBrush);
608
 
    painter->drawPolygon(pa);
609
 
 
610
 
    painter->restore();
611
 
}
612