Repository navigation
Expand file tree
/
Copy pathcommondial.cpp
More file actions
75 lines (56 loc) · 1.94 KB
/
Copy pathcommondial.cpp
File metadata and controls
75 lines (56 loc) · 1.94 KB
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
#include "commondial.h"
#include <qpainter.h>
#include <qwt_dial_needle.h>
#include <qwt_round_scale_draw.h>
CommonDial::CommonDial( QWidget *parent ):
QwtDial( parent ),
d_label( "" )
{
QwtRoundScaleDraw *scaleDraw = new QwtRoundScaleDraw();
scaleDraw->setSpacing( 3 );
scaleDraw->enableComponent( QwtAbstractScaleDraw::Backbone, false );
scaleDraw->setTickLength( QwtScaleDiv::MinorTick, 0 );
scaleDraw->setTickLength( QwtScaleDiv::MediumTick, 4 );
scaleDraw->setTickLength( QwtScaleDiv::MajorTick, 8 );
setScaleDraw( scaleDraw );
setWrapping( false );
setReadOnly( true );
setOrigin( 135.0);
setScaleArc( 0.0, 270.0 );
QwtDialSimpleNeedle *needle = new QwtDialSimpleNeedle(
QwtDialSimpleNeedle::Arrow, true, Qt::red,
QColor( Qt::gray ).light( 130 ) );
setNeedle( needle );
}
void CommonDial::setLabel( const QString &label )
{
d_label = label;
update();
}
QString CommonDial::label() const
{
return d_label;
}
void CommonDial::drawScaleContents( QPainter *painter,
const QPointF ¢er, double radius ) const
{
QRectF rect( 0.0, 0.0, 2.0 * radius, 2.0 * radius - 10.0 );
rect.moveCenter( center );
const QColor color(0xff,0xff,0xff,200); //= palette().color( QPalette::Text );
painter->setPen( color );
QFont font( "Times", 12);
painter->setFont(font);
const int flags = Qt::AlignBottom | Qt::AlignHCenter;
painter->drawText( rect, flags, d_label );
// QRectF rect( 0.0, 0.0, 2.0 * radius, 2.0 * radius - 10.0 );
// rect.moveCenter( center );
// const QColor color(0x45,0x45,0x45,255); //= palette().color( QPalette::Text );
// painter->setPen( color );
// QFont font( "Times", 20);
// painter->setFont(font);
// painter->translate(100,180);
// const int flags = Qt::AlignBottom | Qt::AlignHCenter;
// QTextDocument td;
// td.setHtml("K<sub>max</sub>=K<sub>2</sub> · 3");
// td.drawContents(painter);
}