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 #include <qsize.h>
00016
00017 class QwtPlot;
00018 class QwtScaleMap;
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 #if QT_VERSION >= 0x040500
00030 class QSvgGenerator;
00031 #endif
00032 #endif
00033 #endif
00034
00039 class QWT_EXPORT QwtPlotRenderer: public QObject
00040 {
00041 Q_OBJECT
00042
00043 public:
00045 enum DiscardFlag
00046 {
00048 DiscardNone = 0x00,
00049
00051 DiscardBackground = 0x01,
00052
00054 DiscardTitle = 0x02,
00055
00057 DiscardLegend = 0x04,
00058
00060 DiscardCanvasBackground = 0x08,
00061
00063 DiscardFooter = 0x10,
00064
00072 DiscardCanvasFrame = 0x20
00073
00074 };
00075
00077 typedef QFlags<DiscardFlag> DiscardFlags;
00078
00083 enum LayoutFlag
00084 {
00086 DefaultLayout = 0x00,
00087
00092 FrameWithScales = 0x01
00093 };
00094
00096 typedef QFlags<LayoutFlag> LayoutFlags;
00097
00098 explicit QwtPlotRenderer( QObject * = NULL );
00099 virtual ~QwtPlotRenderer();
00100
00101 void setDiscardFlag( DiscardFlag flag, bool on = true );
00102 bool testDiscardFlag( DiscardFlag flag ) const;
00103
00104 void setDiscardFlags( DiscardFlags flags );
00105 DiscardFlags discardFlags() const;
00106
00107 void setLayoutFlag( LayoutFlag flag, bool on = true );
00108 bool testLayoutFlag( LayoutFlag flag ) const;
00109
00110 void setLayoutFlags( LayoutFlags flags );
00111 LayoutFlags layoutFlags() const;
00112
00113 void renderDocument( QwtPlot *, const QString &fileName,
00114 const QSizeF &sizeMM, int resolution = 85 );
00115
00116 void renderDocument( QwtPlot *,
00117 const QString &fileName, const QString &format,
00118 const QSizeF &sizeMM, int resolution = 85 );
00119
00120 #ifndef QWT_NO_SVG
00121 #ifdef QT_SVG_LIB
00122 #if QT_VERSION >= 0x040500
00123 void renderTo( QwtPlot *, QSvgGenerator & ) const;
00124 #endif
00125 #endif
00126 #endif
00127
00128 #ifndef QT_NO_PRINTER
00129 void renderTo( QwtPlot *, QPrinter & ) const;
00130 #endif
00131
00132 void renderTo( QwtPlot *, QPaintDevice &p ) const;
00133
00134 virtual void render( QwtPlot *,
00135 QPainter *, const QRectF &rect ) const;
00136
00137 virtual void renderTitle( const QwtPlot *,
00138 QPainter *, const QRectF & ) const;
00139
00140 virtual void renderFooter( const QwtPlot *,
00141 QPainter *, const QRectF & ) const;
00142
00143 virtual void renderScale( const QwtPlot *, QPainter *,
00144 int axisId, int startDist, int endDist,
00145 int baseDist, const QRectF & ) const;
00146
00147 virtual void renderCanvas( const QwtPlot *,
00148 QPainter *, const QRectF &canvasRect,
00149 const QwtScaleMap* maps ) const;
00150
00151 virtual void renderLegend(
00152 const QwtPlot *, QPainter *, const QRectF & ) const;
00153
00154 bool exportTo( QwtPlot *, const QString &documentName,
00155 const QSizeF &sizeMM = QSizeF( 300, 200 ), int resolution = 85 );
00156
00157 private:
00158 void buildCanvasMaps( const QwtPlot *,
00159 const QRectF &, QwtScaleMap maps[] ) const;
00160
00161 bool updateCanvasMargins( QwtPlot *,
00162 const QRectF &, const QwtScaleMap maps[] ) const;
00163
00164 private:
00165 class PrivateData;
00166 PrivateData *d_data;
00167 };
00168
00169 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRenderer::DiscardFlags )
00170 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRenderer::LayoutFlags )
00171
00172 #endif