Qwt User's Guide
qwt_plot_renderer.h
00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
00002  * Qwt Widget Library
00003  * Copyright (C) 1997   Josef Wilgen
00004  * Copyright (C) 2002   Uwe Rathmann
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the Qwt License, Version 1.0
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 class QSvgGenerator;
00030 #endif
00031 #endif
00032 
00037 class QWT_EXPORT QwtPlotRenderer: public QObject
00038 {
00039     Q_OBJECT
00040 
00041 public:
00043     enum DiscardFlag
00044     {
00046         DiscardNone             = 0x00,
00047 
00049         DiscardBackground       = 0x01,
00050 
00052         DiscardTitle            = 0x02,
00053 
00055         DiscardLegend           = 0x04,
00056 
00058         DiscardCanvasBackground = 0x08,
00059 
00061         DiscardFooter           = 0x10,
00062 
00070         DiscardCanvasFrame           = 0x20
00071 
00072     };
00073 
00075     typedef QFlags<DiscardFlag> DiscardFlags;
00076 
00081     enum LayoutFlag
00082     {
00084         DefaultLayout   = 0x00,
00085 
00090         FrameWithScales = 0x01
00091     };
00092 
00094     typedef QFlags<LayoutFlag> LayoutFlags;
00095 
00096     explicit QwtPlotRenderer( QObject * = NULL );
00097     virtual ~QwtPlotRenderer();
00098 
00099     void setDiscardFlag( DiscardFlag flag, bool on = true );
00100     bool testDiscardFlag( DiscardFlag flag ) const;
00101 
00102     void setDiscardFlags( DiscardFlags flags );
00103     DiscardFlags discardFlags() const;
00104 
00105     void setLayoutFlag( LayoutFlag flag, bool on = true );
00106     bool testLayoutFlag( LayoutFlag flag ) const;
00107 
00108     void setLayoutFlags( LayoutFlags flags );
00109     LayoutFlags layoutFlags() const;
00110 
00111     void renderDocument( QwtPlot *, const QString &fileName,
00112         const QSizeF &sizeMM, int resolution = 85 );
00113 
00114     void renderDocument( QwtPlot *,
00115         const QString &fileName, const QString &format,
00116         const QSizeF &sizeMM, int resolution = 85 );
00117 
00118 #ifndef QWT_NO_SVG
00119 #ifdef QT_SVG_LIB
00120 #if QT_VERSION >= 0x040500
00121     void renderTo( QwtPlot *, QSvgGenerator & ) const;
00122 #endif
00123 #endif
00124 #endif
00125 
00126 #ifndef QT_NO_PRINTER
00127     void renderTo( QwtPlot *, QPrinter & ) const;
00128 #endif
00129 
00130     void renderTo( QwtPlot *, QPaintDevice &p ) const;
00131 
00132     virtual void render( QwtPlot *,
00133         QPainter *, const QRectF &rect ) const;
00134 
00135     virtual void renderTitle( const QwtPlot *,
00136         QPainter *, const QRectF & ) const;
00137 
00138     virtual void renderFooter( 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     bool exportTo( QwtPlot *, const QString &documentName,
00153         const QSizeF &sizeMM = QSizeF( 300, 200 ), int resolution = 85 );
00154 
00155 private:
00156     void buildCanvasMaps( const QwtPlot *,
00157         const QRectF &, QwtScaleMap maps[] ) const;
00158 
00159     bool updateCanvasMargins( QwtPlot *,
00160         const QRectF &, const QwtScaleMap maps[] ) const;
00161 
00162 private:
00163     class PrivateData;
00164     PrivateData *d_data;
00165 };
00166 
00167 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRenderer::DiscardFlags )
00168 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRenderer::LayoutFlags )
00169 
00170 #endif
 All Classes Functions Variables Typedefs Enumerations Enumerator