qwt_scale_draw.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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_SCALE_DRAW_H
  10. #define QWT_SCALE_DRAW_H
  11. #include "qwt_global.h"
  12. #include "qwt_abstract_scale_draw.h"
  13. #include <qpoint.h>
  14. #include <qrect.h>
  15. #include <qtransform.h>
  16. /*!
  17. \brief A class for drawing scales
  18. QwtScaleDraw can be used to draw linear or logarithmic scales.
  19. A scale has a position, an alignment and a length, which can be specified .
  20. The labels can be rotated and aligned
  21. to the ticks using setLabelRotation() and setLabelAlignment().
  22. After a scale division has been specified as a QwtScaleDiv object
  23. using QwtAbstractScaleDraw::setScaleDiv(const QwtScaleDiv &s),
  24. the scale can be drawn with the QwtAbstractScaleDraw::draw() member.
  25. */
  26. class QWT_EXPORT QwtScaleDraw: public QwtAbstractScaleDraw
  27. {
  28. public:
  29. /*!
  30. Alignment of the scale draw
  31. \sa setAlignment(), alignment()
  32. */
  33. enum Alignment { BottomScale, TopScale, LeftScale, RightScale };
  34. QwtScaleDraw();
  35. virtual ~QwtScaleDraw();
  36. void getBorderDistHint( const QFont &, int &start, int &end ) const;
  37. int minLabelDist( const QFont & ) const;
  38. int minLength( const QFont & ) const;
  39. virtual double extent( const QFont & ) const;
  40. void move( double x, double y );
  41. void move( const QPointF & );
  42. void setLength( double length );
  43. Alignment alignment() const;
  44. void setAlignment( Alignment );
  45. Qt::Orientation orientation() const;
  46. QPointF pos() const;
  47. double length() const;
  48. void setLabelAlignment( Qt::Alignment );
  49. Qt::Alignment labelAlignment() const;
  50. void setLabelRotation( double rotation );
  51. double labelRotation() const;
  52. int maxLabelHeight( const QFont & ) const;
  53. int maxLabelWidth( const QFont & ) const;
  54. QPointF labelPosition( double val ) const;
  55. QRectF labelRect( const QFont &, double val ) const;
  56. QSizeF labelSize( const QFont &, double val ) const;
  57. QRect boundingLabelRect( const QFont &, double val ) const;
  58. protected:
  59. QTransform labelTransformation( const QPointF &, const QSizeF & ) const;
  60. virtual void drawTick( QPainter *, double val, double len ) const;
  61. virtual void drawBackbone( QPainter * ) const;
  62. virtual void drawLabel( QPainter *, double val ) const;
  63. private:
  64. QwtScaleDraw( const QwtScaleDraw & );
  65. QwtScaleDraw &operator=( const QwtScaleDraw &other );
  66. void updateMap();
  67. class PrivateData;
  68. PrivateData *d_data;
  69. };
  70. /*!
  71. Move the position of the scale
  72. \sa move(const QPointF &)
  73. */
  74. inline void QwtScaleDraw::move( double x, double y )
  75. {
  76. move( QPointF( x, y ) );
  77. }
  78. #endif