qwt_plot_layout.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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_LAYOUT_H
  10. #define QWT_PLOT_LAYOUT_H
  11. #include "qwt_global.h"
  12. #include "qwt_plot.h"
  13. /*!
  14. \brief Layout engine for QwtPlot.
  15. It is used by the QwtPlot widget to organize its internal widgets
  16. or by QwtPlot::print() to render its content to a QPaintDevice like
  17. a QPrinter, QPixmap/QImage or QSvgRenderer.
  18. */
  19. class QWT_EXPORT QwtPlotLayout
  20. {
  21. public:
  22. /*!
  23. Options to configure the plot layout engine
  24. - AlignScales\n
  25. Unused
  26. - IgnoreScrollbars\n
  27. Ignore the dimension of the scrollbars. There are no
  28. scrollbars, when the plot is rendered to a paint device
  29. (QwtPlot::print() ).
  30. - IgnoreFrames\n
  31. Ignore all frames. QwtPlot::print() doesn't paint them.
  32. - IgnoreMargin\n
  33. Ignore the margin().
  34. - IgnoreLegend\n
  35. Ignore the legend.
  36. \sa activate()
  37. */
  38. enum Options
  39. {
  40. AlignScales = 1,
  41. IgnoreScrollbars = 2,
  42. IgnoreFrames = 4,
  43. IgnoreMargin = 8,
  44. IgnoreLegend = 16
  45. };
  46. explicit QwtPlotLayout();
  47. virtual ~QwtPlotLayout();
  48. void setMargin( int );
  49. int margin() const;
  50. void setCanvasMargin( int margin, int axis = -1 );
  51. int canvasMargin( int axis ) const;
  52. void setAlignCanvasToScales( bool );
  53. bool alignCanvasToScales() const;
  54. void setSpacing( int );
  55. int spacing() const;
  56. void setLegendPosition( QwtPlot::LegendPosition pos, double ratio );
  57. void setLegendPosition( QwtPlot::LegendPosition pos );
  58. QwtPlot::LegendPosition legendPosition() const;
  59. void setLegendRatio( double ratio );
  60. double legendRatio() const;
  61. virtual QSize minimumSizeHint( const QwtPlot * ) const;
  62. virtual void activate( const QwtPlot *,
  63. const QRectF &rect, int options = 0 );
  64. virtual void invalidate();
  65. const QRectF &titleRect() const;
  66. const QRectF &legendRect() const;
  67. const QRectF &scaleRect( int axis ) const;
  68. const QRectF &canvasRect() const;
  69. class LayoutData;
  70. protected:
  71. QRectF layoutLegend( int options, const QRectF & ) const;
  72. QRectF alignLegend( const QRectF &canvasRect,
  73. const QRectF &legendRect ) const;
  74. void expandLineBreaks( int options, const QRectF &rect,
  75. int &dimTitle, int dimAxes[QwtPlot::axisCnt] ) const;
  76. void alignScales( int options, QRectF &canvasRect,
  77. QRectF scaleRect[QwtPlot::axisCnt] ) const;
  78. private:
  79. class PrivateData;
  80. PrivateData *d_data;
  81. };
  82. #endif