qwt_plot_layout.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. \sa QwtPlot::setPlotLayout()
  19. */
  20. class QWT_EXPORT QwtPlotLayout
  21. {
  22. public:
  23. /*!
  24. Options to configure the plot layout engine
  25. \sa activate(), QwtPlotRenderer
  26. */
  27. enum Option
  28. {
  29. //! Unused
  30. AlignScales = 0x01,
  31. /*!
  32. Ignore the dimension of the scrollbars. There are no
  33. scrollbars, when the plot is not rendered to widgets.
  34. */
  35. IgnoreScrollbars = 0x02,
  36. //! Ignore all frames.
  37. IgnoreFrames = 0x04,
  38. //! Ignore the legend.
  39. IgnoreLegend = 0x08,
  40. //! Ignore the title.
  41. IgnoreTitle = 0x10,
  42. //! Ignore the footer.
  43. IgnoreFooter = 0x20
  44. };
  45. //! Layout options
  46. typedef QFlags<Option> Options;
  47. explicit QwtPlotLayout();
  48. virtual ~QwtPlotLayout();
  49. void setCanvasMargin( int margin, int axis = -1 );
  50. int canvasMargin( int axisId ) const;
  51. void setAlignCanvasToScales( bool );
  52. void setAlignCanvasToScale( int axisId, bool );
  53. bool alignCanvasToScale( int axisId ) 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 &plotRect, Options options = Options() );
  64. virtual void invalidate();
  65. QRectF titleRect() const;
  66. QRectF footerRect() const;
  67. QRectF legendRect() const;
  68. QRectF scaleRect( int axis ) const;
  69. QRectF canvasRect() const;
  70. class LayoutData;
  71. protected:
  72. void setTitleRect( const QRectF & );
  73. void setFooterRect( const QRectF & );
  74. void setLegendRect( const QRectF & );
  75. void setScaleRect( int axis, const QRectF & );
  76. void setCanvasRect( const QRectF & );
  77. QRectF layoutLegend( Options options, const QRectF & ) const;
  78. QRectF alignLegend( const QRectF &canvasRect,
  79. const QRectF &legendRect ) const;
  80. void expandLineBreaks( Options options, const QRectF &rect,
  81. int &dimTitle, int &dimFooter, int dimAxes[QwtPlot::axisCnt] ) const;
  82. void alignScales( Options options, QRectF &canvasRect,
  83. QRectF scaleRect[QwtPlot::axisCnt] ) const;
  84. private:
  85. class PrivateData;
  86. PrivateData *d_data;
  87. };
  88. Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotLayout::Options )
  89. #endif