qwt_plot_scaleitem.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_PLOT_SCALE_ITEM_H
  10. #define QWT_PLOT_SCALE_ITEM_H
  11. #include "qwt_global.h"
  12. #include "qwt_plot_item.h"
  13. #include "qwt_scale_draw.h"
  14. class QPalette;
  15. /*!
  16. \brief A class which draws a scale inside the plot canvas
  17. QwtPlotScaleItem can be used to draw an axis inside the plot canvas.
  18. It might by synchronized to one of the axis of the plot, but can
  19. also display its own ticks and labels.
  20. It is allowed to synchronize the scale item with a disabled axis.
  21. In plots with vertical and horizontal scale items, it might be
  22. necessary to remove ticks at the intersections, by overloading
  23. updateScaleDiv().
  24. The scale might be at a specific position (f.e 0.0) or it might be
  25. aligned to a canvas border.
  26. \par Example
  27. The following example shows how to replace the left axis, by a scale item
  28. at the x position 0.0.
  29. \code
  30. QwtPlotScaleItem *scaleItem = new QwtPlotScaleItem( QwtScaleDraw::RightScale, 0.0 );
  31. scaleItem->setFont( plot->axisWidget( QwtPlot::yLeft )->font() );
  32. scaleItem->attach(plot);
  33. plot->enableAxis( QwtPlot::yLeft, false );
  34. \endcode
  35. \endpar
  36. */
  37. class QWT_EXPORT QwtPlotScaleItem: public QwtPlotItem
  38. {
  39. public:
  40. explicit QwtPlotScaleItem(
  41. QwtScaleDraw::Alignment = QwtScaleDraw::BottomScale,
  42. const double pos = 0.0 );
  43. virtual ~QwtPlotScaleItem();
  44. virtual int rtti() const;
  45. void setScaleDiv( const QwtScaleDiv& );
  46. const QwtScaleDiv& scaleDiv() const;
  47. void setScaleDivFromAxis( bool on );
  48. bool isScaleDivFromAxis() const;
  49. void setPalette( const QPalette & );
  50. QPalette palette() const;
  51. void setFont( const QFont& );
  52. QFont font() const;
  53. void setScaleDraw( QwtScaleDraw * );
  54. const QwtScaleDraw *scaleDraw() const;
  55. QwtScaleDraw *scaleDraw();
  56. void setPosition( double pos );
  57. double position() const;
  58. void setBorderDistance( int );
  59. int borderDistance() const;
  60. void setAlignment( QwtScaleDraw::Alignment );
  61. virtual void draw( QPainter *,
  62. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  63. const QRectF &canvasRect ) const;
  64. virtual void updateScaleDiv( const QwtScaleDiv &, const QwtScaleDiv & );
  65. private:
  66. class PrivateData;
  67. PrivateData *d_data;
  68. };
  69. #endif