00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef QWT_PLOT_RENDERER_H
00011 #define QWT_PLOT_RENDERER_H
00012
00013 #include "qwt_global.h"
00014 #include <qobject.h>
00015
00016 class QwtPlot;
00017 class QwtScaleMap;
00018 class QSizeF;
00019 class QRectF;
00020 class QPainter;
00021 class QPaintDevice;
00022
00023 #ifndef QT_NO_PRINTER
00024 class QPrinter;
00025 #endif
00026
00027 #ifndef QWT_NO_SVG
00028 #ifdef QT_SVG_LIB
00029 class QSvgGenerator;
00030 #endif
00031 #endif
00032
00037 class QWT_EXPORT QwtPlotRenderer: public QObject
00038 {
00039 Q_OBJECT
00040
00041 public:
00058 enum DiscardFlag
00059 {
00060 DiscardNone = 0x0,
00061
00062 DiscardBackground = 0x1,
00063 DiscardTitle = 0x2,
00064 DiscardLegend = 0x4,
00065 DiscardCanvasBackground = 0x8
00066 };
00067
00068 Q_DECLARE_FLAGS( DiscardFlags, DiscardFlag )
00069
00070
00084 enum LayoutFlag
00085 {
00086 DefaultLayout = 0x0,
00087
00088 KeepMargins = 0x1,
00089 KeepFrames = 0x2,
00090 FrameWithScales = 0x4
00091 };
00092
00093 Q_DECLARE_FLAGS( LayoutFlags, LayoutFlag )
00094
00095 explicit QwtPlotRenderer( QObject * = NULL );
00096 virtual ~QwtPlotRenderer();
00097
00098 void setDiscardFlag( DiscardFlag flag, bool on = true );
00099 bool testDiscardFlag( DiscardFlag flag ) const;
00100
00101 void setDiscardFlags( DiscardFlags flags );
00102 DiscardFlags discardFlags() const;
00103
00104 void setLayoutFlag( LayoutFlag flag, bool on = true );
00105 bool testLayoutFlag( LayoutFlag flag ) const;
00106
00107 void setLayoutFlags( LayoutFlags flags );
00108 LayoutFlags layoutFlags() const;
00109
00110 void renderDocument( QwtPlot *, const QString &format,
00111 const QSizeF &sizeMM, int resolution = 85 );
00112
00113 void renderDocument( QwtPlot *,
00114 const QString &title, const QString &format,
00115 const QSizeF &sizeMM, int resolution = 85 );
00116
00117 #ifndef QWT_NO_SVG
00118 #ifdef QT_SVG_LIB
00119 #if QT_VERSION >= 0x040500
00120 void renderTo( QwtPlot *, QSvgGenerator & ) const;
00121 #endif
00122 #endif
00123 #endif
00124
00125 #ifndef QT_NO_PRINTER
00126 void renderTo( QwtPlot *, QPrinter & ) const;
00127 #endif
00128
00129 void renderTo( QwtPlot *, QPaintDevice &p ) const;
00130
00131 virtual void render( QwtPlot *,
00132 QPainter *, const QRectF &rect ) const;
00133
00134 protected:
00135 virtual void renderLegendItem( const QwtPlot *,
00136 QPainter *, const QWidget *, const QRectF & ) const;
00137
00138 virtual void renderTitle( const QwtPlot *,
00139 QPainter *, const QRectF & ) const;
00140
00141 virtual void renderScale( const QwtPlot *, QPainter *,
00142 int axisId, int startDist, int endDist,
00143 int baseDist, const QRectF & ) const;
00144
00145 virtual void renderCanvas( const QwtPlot *,
00146 QPainter *, const QRectF &canvasRect,
00147 const QwtScaleMap* maps ) const;
00148
00149 virtual void renderLegend(
00150 const QwtPlot *, QPainter *, const QRectF & ) const;
00151
00152 void buildCanvasMaps( const QwtPlot *,
00153 const QRectF &, QwtScaleMap maps[] ) const;
00154
00155 private:
00156 class PrivateData;
00157 PrivateData *d_data;
00158 };
00159
00160 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRenderer::DiscardFlags );
00161 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRenderer::LayoutFlags );
00162
00163 #endif