Qwt User's Guide
svn
|
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 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: 00043 enum DiscardFlag 00044 { 00046 DiscardNone = 0x00, 00047 00049 DiscardBackground = 0x01, 00050 00052 DiscardTitle = 0x02, 00053 00055 DiscardLegend = 0x04, 00056 00058 DiscardCanvasBackground = 0x08 00059 }; 00060 00062 typedef QFlags<DiscardFlag> DiscardFlags; 00063 00068 enum LayoutFlag 00069 { 00071 DefaultLayout = 0x00, 00072 00074 KeepFrames = 0x01, 00075 00080 FrameWithScales = 0x02 00081 }; 00082 00084 typedef QFlags<LayoutFlag> LayoutFlags; 00085 00086 explicit QwtPlotRenderer( QObject * = NULL ); 00087 virtual ~QwtPlotRenderer(); 00088 00089 void setDiscardFlag( DiscardFlag flag, bool on = true ); 00090 bool testDiscardFlag( DiscardFlag flag ) const; 00091 00092 void setDiscardFlags( DiscardFlags flags ); 00093 DiscardFlags discardFlags() const; 00094 00095 void setLayoutFlag( LayoutFlag flag, bool on = true ); 00096 bool testLayoutFlag( LayoutFlag flag ) const; 00097 00098 void setLayoutFlags( LayoutFlags flags ); 00099 LayoutFlags layoutFlags() const; 00100 00101 void renderDocument( QwtPlot *, const QString &fileName, 00102 const QSizeF &sizeMM, int resolution = 85 ); 00103 00104 void renderDocument( QwtPlot *, 00105 const QString &title, const QString &fileName, 00106 const QSizeF &sizeMM, int resolution = 85 ); 00107 00108 #ifndef QWT_NO_SVG 00109 #ifdef QT_SVG_LIB 00110 #if QT_VERSION >= 0x040500 00111 void renderTo( QwtPlot *, QSvgGenerator & ) const; 00112 #endif 00113 #endif 00114 #endif 00115 00116 #ifndef QT_NO_PRINTER 00117 void renderTo( QwtPlot *, QPrinter & ) const; 00118 #endif 00119 00120 void renderTo( QwtPlot *, QPaintDevice &p ) const; 00121 00122 virtual void render( QwtPlot *, 00123 QPainter *, const QRectF &rect ) const; 00124 00125 virtual void renderLegendItem( const QwtPlot *, 00126 QPainter *, const QWidget *, const QRectF & ) const; 00127 00128 virtual void renderTitle( const QwtPlot *, 00129 QPainter *, const QRectF & ) const; 00130 00131 virtual void renderScale( const QwtPlot *, QPainter *, 00132 int axisId, int startDist, int endDist, 00133 int baseDist, const QRectF & ) const; 00134 00135 virtual void renderCanvas( const QwtPlot *, 00136 QPainter *, const QRectF &canvasRect, 00137 const QwtScaleMap* maps ) const; 00138 00139 virtual void renderLegend( 00140 const QwtPlot *, QPainter *, const QRectF & ) const; 00141 00142 protected: 00143 void buildCanvasMaps( const QwtPlot *, 00144 const QRectF &, QwtScaleMap maps[] ) const; 00145 00146 private: 00147 class PrivateData; 00148 PrivateData *d_data; 00149 }; 00150 00151 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRenderer::DiscardFlags ) 00152 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRenderer::LayoutFlags ) 00153 00154 #endif