qwt_thermo.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. #ifndef QWT_THERMO_H
  10. #define QWT_THERMO_H
  11. #include "qwt_global.h"
  12. #include "qwt_abstract_scale.h"
  13. #include "qwt_interval.h"
  14. class QwtScaleDraw;
  15. class QwtColorMap;
  16. /*!
  17. \brief The Thermometer Widget
  18. QwtThermo is a widget which displays a value in an interval. It supports:
  19. - a horizontal or vertical layout;
  20. - a range;
  21. - a scale;
  22. - an alarm level.
  23. \image html sysinfo.png
  24. The fill colors might be calculated from an optional color map
  25. If no color map has been assigned QwtThermo uses the
  26. following colors/brushes from the widget palette:
  27. - QPalette::Base
  28. Background of the pipe
  29. - QPalette::ButtonText
  30. Fill brush below the alarm level
  31. - QPalette::Highlight
  32. Fill brush for the values above the alarm level
  33. - QPalette::WindowText
  34. For the axis of the scale
  35. - QPalette::Text
  36. For the labels of the scale
  37. */
  38. class QWT_EXPORT QwtThermo: public QwtAbstractScale
  39. {
  40. Q_OBJECT
  41. Q_ENUMS( ScalePosition )
  42. Q_ENUMS( OriginMode )
  43. Q_PROPERTY( Qt::Orientation orientation
  44. READ orientation WRITE setOrientation )
  45. Q_PROPERTY( ScalePosition scalePosition
  46. READ scalePosition WRITE setScalePosition )
  47. Q_PROPERTY( OriginMode originMode READ originMode WRITE setOriginMode )
  48. Q_PROPERTY( bool alarmEnabled READ alarmEnabled WRITE setAlarmEnabled )
  49. Q_PROPERTY( double alarmLevel READ alarmLevel WRITE setAlarmLevel )
  50. Q_PROPERTY( double origin READ origin WRITE setOrigin )
  51. Q_PROPERTY( int spacing READ spacing WRITE setSpacing )
  52. Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
  53. Q_PROPERTY( int pipeWidth READ pipeWidth WRITE setPipeWidth )
  54. Q_PROPERTY( double value READ value WRITE setValue )
  55. public:
  56. /*!
  57. Position of the scale
  58. \sa setScalePosition(), setOrientation()
  59. */
  60. enum ScalePosition
  61. {
  62. //! The slider has no scale
  63. NoScale,
  64. //! The scale is right of a vertical or below of a horizontal slider
  65. LeadingScale,
  66. //! The scale is left of a vertical or above of a horizontal slider
  67. TrailingScale
  68. };
  69. /*!
  70. Origin mode. This property specifies where the beginning of the liquid
  71. is placed.
  72. \sa setOriginMode(), setOrigin()
  73. */
  74. enum OriginMode
  75. {
  76. //! The origin is the minimum of the scale
  77. OriginMinimum,
  78. //! The origin is the maximum of the scale
  79. OriginMaximum,
  80. //! The origin is specified using the origin() property
  81. OriginCustom
  82. };
  83. explicit QwtThermo( QWidget *parent = NULL );
  84. virtual ~QwtThermo();
  85. void setOrientation( Qt::Orientation );
  86. Qt::Orientation orientation() const;
  87. void setScalePosition( ScalePosition );
  88. ScalePosition scalePosition() const;
  89. void setSpacing( int );
  90. int spacing() const;
  91. void setBorderWidth( int );
  92. int borderWidth() const;
  93. void setOriginMode( OriginMode );
  94. OriginMode originMode() const;
  95. void setOrigin( double );
  96. double origin() const;
  97. void setFillBrush( const QBrush & );
  98. QBrush fillBrush() const;
  99. void setAlarmBrush( const QBrush & );
  100. QBrush alarmBrush() const;
  101. void setAlarmLevel( double );
  102. double alarmLevel() const;
  103. void setAlarmEnabled( bool );
  104. bool alarmEnabled() const;
  105. void setColorMap( QwtColorMap * );
  106. QwtColorMap *colorMap();
  107. const QwtColorMap *colorMap() const;
  108. void setPipeWidth( int );
  109. int pipeWidth() const;
  110. void setRangeFlags( QwtInterval::BorderFlags );
  111. QwtInterval::BorderFlags rangeFlags() const;
  112. double value() const;
  113. virtual QSize sizeHint() const;
  114. virtual QSize minimumSizeHint() const;
  115. void setScaleDraw( QwtScaleDraw * );
  116. const QwtScaleDraw *scaleDraw() const;
  117. public Q_SLOTS:
  118. virtual void setValue( double );
  119. protected:
  120. virtual void drawLiquid( QPainter *, const QRect & ) const;
  121. virtual void scaleChange();
  122. virtual void paintEvent( QPaintEvent * );
  123. virtual void resizeEvent( QResizeEvent * );
  124. virtual void changeEvent( QEvent * );
  125. QwtScaleDraw *scaleDraw();
  126. QRect pipeRect() const;
  127. QRect fillRect( const QRect & ) const;
  128. QRect alarmRect( const QRect & ) const;
  129. private:
  130. void layoutThermo( bool );
  131. class PrivateData;
  132. PrivateData *d_data;
  133. };
  134. #endif