Newer
Older
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Qwt License, Version 1.0
*****************************************************************************/
#include "qwt_scale_engine.h"
#include "qwt_scale_draw.h"
#include "qwt_scale_map.h"
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
#include "qwt_color_map.h"
#include <qpainter.h>
#include <qevent.h>
#include <qdrawutil.h>
#include <qstyle.h>
#include <qstyleoption.h>
#include <qmath.h>
static inline void qwtDrawLine( QPainter *painter, int pos,
const QColor &color, const QRect &pipeRect, const QRect &liquidRect,
Qt::Orientation orientation )
{
painter->setPen( color );
if ( orientation == Qt::Horizontal )
{
if ( pos >= liquidRect.left() && pos < liquidRect.right() )
painter->drawLine( pos, pipeRect.top(), pos, pipeRect.bottom() );
}
else
{
if ( pos >= liquidRect.top() && pos < liquidRect.bottom() )
painter->drawLine( pipeRect.left(), pos, pipeRect.right(), pos );
}
}
QVector<double> qwtTickList( const QwtScaleDiv &scaleDiv )
{
QVector<double> values;
double lowerLimit = scaleDiv.interval().minValue();
double upperLimit = scaleDiv.interval().maxValue();
if ( upperLimit < lowerLimit )
qSwap( lowerLimit, upperLimit );
values += lowerLimit;
for ( int tickType = QwtScaleDiv::MinorTick;
tickType < QwtScaleDiv::NTickTypes; tickType++ )
{
const QList<double> ticks = scaleDiv.ticks( tickType );
for ( int i = 0; i < ticks.count(); i++ )
{
const double v = ticks[i];
if ( v > lowerLimit && v < upperLimit )
values += v;
}
}
values += upperLimit;
return values;
}
class QwtThermo::PrivateData
{
public:
PrivateData():
orientation( Qt::Vertical ),
scalePosition( QwtThermo::TrailingScale ),
spacing( 3 ),
borderWidth( 2 ),
pipeWidth( 10 ),
alarmLevel( 0.0 ),
alarmEnabled( false ),
autoFillPipe( true ),
originMode( QwtThermo::OriginMinimum ),
origin( 0.0 ),
colorMap( NULL ),
value( 0.0 )
{
rangeFlags = QwtInterval::IncludeBorders;
}
~PrivateData()
{
delete colorMap;
}
bool autoFillPipe;
QwtThermo::OriginMode originMode;
double origin;
QwtThermo::QwtThermo( QWidget *parent ):
QwtAbstractScale( parent )
QSizePolicy policy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
if ( d_data->orientation == Qt::Vertical )
setAttribute( Qt::WA_WState_OwnSizePolicy, false );
layoutThermo( true );
}
//! Destructor
QwtThermo::~QwtThermo()
{
delete d_data;
}
According to the flags minValue() and maxValue()
are included/excluded from the pipe. In case of an
excluded value the corresponding tick is painted
1 pixel off of the pipeRect().
F.e. when a minimum
of 0.0 has to be displayed as an empty pipe the minValue()
needs to be excluded.
\param flags Range flags
\sa rangeFlags()
*/
void QwtThermo::setRangeFlags( QwtInterval::BorderFlags flags )
if ( d_data->rangeFlags != flags )
{
d_data->rangeFlags = flags;
update();
}
/*!
\return Range flags
\sa setRangeFlags()
*/
QwtInterval::BorderFlags QwtThermo::rangeFlags() const
/*!
Set the current value.
\param value New Value
\sa value()
*/
void QwtThermo::setValue( double value )
if ( d_data->value != value )
{
d_data->value = value;
double QwtThermo::value() const
{
return d_data->value;
}
/*!
\brief Set a scale draw
For changing the labels of the scales, it
is necessary to derive from QwtScaleDraw and
overload QwtScaleDraw::label().
\param scaleDraw ScaleDraw object, that has to be created with
Loading
Loading full blame...