17 #include <qdrawutil.h> 19 #include <qstyleoption.h> 23 const QColor &color,
const QRect &pipeRect,
const QRect &liquidRect,
24 Qt::Orientation orientation )
26 painter->setPen( color );
27 if ( orientation == Qt::Horizontal )
29 if ( pos >= liquidRect.left() && pos < liquidRect.right() )
30 painter->drawLine( pos, pipeRect.top(), pos, pipeRect.bottom() );
34 if ( pos >= liquidRect.top() && pos < liquidRect.bottom() )
35 painter->drawLine( pipeRect.left(), pos, pipeRect.right(), pos );
46 if ( upperLimit < lowerLimit )
47 qSwap( lowerLimit, upperLimit );
54 const QList<double> ticks = scaleDiv.
ticks( tickType );
56 for (
int i = 0;
i < ticks.count();
i++ )
58 const double v = ticks[
i];
59 if ( v > lowerLimit && v < upperLimit )
122 QSizePolicy policy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
126 setSizePolicy( policy );
128 setAttribute( Qt::WA_WState_OwnSizePolicy,
false );
233 QPainter painter(
this );
234 painter.setClipRegion( event->region() );
238 style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter,
this);
242 if ( !tRect.contains( event->rect() ) )
250 const QBrush brush = palette().brush( QPalette::Base );
251 qDrawShadePanel( &painter,
252 tRect.adjusted( -bw, -bw, bw, bw ),
275 switch( event->type() )
277 case QEvent::StyleChange:
278 case QEvent::FontChange:
370 if ( update_geometry )
388 mbd = qMax( d1, d2 );
391 const int scaleOff = bw + mbd;
393 const QRect cr = contentsRect();
398 pipeRect.adjust( scaleOff, 0, -scaleOff, 0 );
403 pipeRect.setTop( bw );
409 pipeRect.adjust( 0, scaleOff, 0, -scaleOff );
412 pipeRect.setLeft( bw );
435 if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) )
437 QSizePolicy sp = sizePolicy();
441 setAttribute( Qt::WA_WState_OwnSizePolicy,
false );
518 if ( testAttribute( Qt::WA_WState_Polished ) )
543 QPainter *painter,
const QRect &
pipeRect )
const 546 painter->setClipRect( pipeRect, Qt::IntersectClip );
547 painter->setPen( Qt::NoPen );
551 QRect liquidRect =
fillRect( pipeRect );
563 qSort( values.begin(), values.end(), qGreater<double>() );
565 qSort( values.begin(), values.end(), qLess<double>() );
568 if ( !values.isEmpty() )
570 from = qRound( scaleMap.
transform( values[0] ) );
576 for (
int i = 1;
i < values.size();
i++ )
578 const int to = qRound( scaleMap.
transform( values[
i] ) );
580 for (
int pos = from + 1; pos < to; pos++ )
603 painter->fillRect( r, palette().brush( QPalette::Highlight ) );
604 liquidRect = QRegion( liquidRect ).subtracted( r ).boundingRect();
608 painter->fillRect( liquidRect, palette().brush( QPalette::ButtonText ) );
718 QPalette pal = palette();
719 pal.setBrush( QPalette::ButtonText, brush );
729 return palette().brush( QPalette::ButtonText );
745 QPalette pal = palette();
746 pal.setBrush( QPalette::Highlight, brush );
759 return palette().brush( QPalette::Highlight );
858 const int sdExtent = qCeil(
scaleDraw()->extent( font() ) );
878 int left, right, top, bottom;
879 getContentsMargins( &left, &top, &right, &bottom );
883 return QSize( w, h );
921 fillRect.setLeft( from );
922 fillRect.setRight( to );
926 fillRect.setTop( from );
927 fillRect.setBottom( to );
930 return fillRect.normalized();
969 v1 = fillRect.left();
972 v2 = qMin( v2, increasing ? fillRect.right() : valuePos );
977 v1 = qMax( v1, increasing ? fillRect.left() : valuePos );
979 v2 = fillRect.right();
982 alarmRect.setRect( v1, fillRect.top(), v2 - v1 + 1, fillRect.height() );
990 v1 = qMax( v1, increasing ? fillRect.top() : valuePos );
992 v2 = fillRect.bottom();
999 v2 = qMin( v2, increasing ? fillRect.bottom() : valuePos );
1001 alarmRect.setRect( fillRect.left(), v1, fillRect.width(), v2 - v1 + 1 );
void setBorderWidth(int w)
The scale is right of a vertical or below of a horizontal slider.
double alarmLevel() const
void setScalePosition(ScalePosition)
Change the position of the scale.
QwtInterval normalized() const
Normalize the limits of the interval.
An abstract base class for widgets having a scale.
QFlags< BorderFlag > BorderFlags
Border flags.
void setAlignment(Alignment)
The origin is specified using the origin() property.
void setLength(double length)
Qt::Orientation orientation() const
The scale is left of a vertical or above of a horizontal slider.
void setAbstractScaleDraw(QwtAbstractScaleDraw *)
Set a scale draw.
void setColorMap(QwtColorMap *)
Assign a color map for the fill color.
std::vector< double > values
A class representing an interval.
virtual void scaleChange()
Notify a scale change.
virtual void paintEvent(QPaintEvent *)
OriginMode originMode() const
Max value is not included in the interval.
The origin is the minimum of the scale.
void setRangeFlags(QwtInterval::BorderFlags)
Exclude/Include min/max values.
void setSpacing(int)
Change the spacing between pipe and scale.
QwtThermo(QWidget *parent=NULL)
virtual void resizeEvent(QResizeEvent *)
const QwtScaleMap & scaleMap() const
QVector< double > qwtTickList(const QwtScaleDiv &scaleDiv)
static void qwtDrawLine(QPainter *painter, int pos, const QColor &color, const QRect &pipeRect, const QRect &liquidRect, Qt::Orientation orientation)
A class representing a scale division.
Qt::Orientation orientation
const QwtScaleMap & scaleMap() const
void getBorderDistHint(const QFont &, int &start, int &end) const
Determine the minimum border distance.
int minLength(const QFont &) const
void setOriginMode(OriginMode)
Change how the origin is determined.
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
QBrush alarmBrush() const
The origin is the maximum of the scale.
const QwtScaleDiv & scaleDiv() const
QwtColorMap is used to map values into colors.
Min value is not included in the interval.
const QwtAbstractScaleDraw * abstractScaleDraw() const
QColor color(const QwtInterval &, double value) const
double invTransform(double p) const
Number of valid tick types.
virtual QSize sizeHint() const
QwtThermo::ScalePosition scalePosition
void setFillBrush(const QBrush &b)
Change the brush of the liquid.
virtual QSize minimumSizeHint() const
QwtInterval::BorderFlags rangeFlags
TFSIMD_FORCE_INLINE const tfScalar & w() const
void setAlarmLevel(double v)
QwtThermo::OriginMode originMode
virtual ~QwtThermo()
Destructor.
virtual void draw(QPainter *, const QPalette &) const
Draw the scale.
double lowerBound() const
QwtInterval::BorderFlags rangeFlags() const
bool alarmEnabled() const
const QwtScaleDraw * scaleDraw() const
void setOrientation(Qt::Orientation)
Set the orientation.
void setScaleDraw(QwtScaleDraw *)
Set a scale draw.
QwtInterval interval() const
A class for drawing scales.
ScalePosition scalePosition() const
void setAlarmEnabled(bool tf)
Enable or disable the alarm threshold.
void setOrigin(double)
Specifies the custom origin.
double transform(double s) const
double upperBound() const
QRect fillRect(const QRect &) const
Calculate the filled rectangle of the pipe.
void setAlarmBrush(const QBrush &b)
Specify the liquid brush above the alarm threshold.
QList< double > ticks(int tickType) const
virtual void setValue(double val)
virtual void drawLiquid(QPainter *, const QRect &) const
virtual void changeEvent(QEvent *)
Min/Max values are inside the interval.
void move(double x, double y)
QRect alarmRect(const QRect &) const
Calculate the alarm rectangle of the pipe.