source: ntrip/trunk/BNC/qwt/qwt_plot_renderer.h@ 6471

Last change on this file since 6471 was 4271, checked in by mervart, 12 years ago
File size: 3.9 KB
Line 
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
10#ifndef QWT_PLOT_RENDERER_H
11#define QWT_PLOT_RENDERER_H
12
13#include "qwt_global.h"
14#include <qobject.h>
15
16class QwtPlot;
17class QwtScaleMap;
18class QSizeF;
19class QRectF;
20class QPainter;
21class QPaintDevice;
22
23#ifndef QT_NO_PRINTER
24class QPrinter;
25#endif
26
27#ifndef QWT_NO_SVG
28#ifdef QT_SVG_LIB
29class QSvgGenerator;
30#endif
31#endif
32
33/*!
34 \brief Renderer for exporting a plot to a document, a printer
35 or anything else, that is supported by QPainter/QPaintDevice
36*/
37class QWT_EXPORT QwtPlotRenderer: public QObject
38{
39 Q_OBJECT
40
41public:
42 //! Disard flags
43 enum DiscardFlag
44 {
45 //! Render all components of the plot
46 DiscardNone = 0x00,
47
48 //! Don't render the background of the plot
49 DiscardBackground = 0x01,
50
51 //! Don't render the title of the plot
52 DiscardTitle = 0x02,
53
54 //! Don't render the legend of the plot
55 DiscardLegend = 0x04,
56
57 //! Don't render the background of the canvas
58 DiscardCanvasBackground = 0x08
59 };
60
61 //! Disard flags
62 typedef QFlags<DiscardFlag> DiscardFlags;
63
64 /*!
65 \brief Layout flags
66 \sa setLayoutFlag(), testLayoutFlag()
67 */
68 enum LayoutFlag
69 {
70 //! Use the default layout without margins and frames
71 DefaultLayout = 0x00,
72
73 //! Render all frames of the plot
74 KeepFrames = 0x01,
75
76 /*!
77 Instead of the scales a box is painted around the plot canvas,
78 where the scale ticks are aligned to.
79 */
80 FrameWithScales = 0x02
81 };
82
83 //! Layout flags
84 typedef QFlags<LayoutFlag> LayoutFlags;
85
86 explicit QwtPlotRenderer( QObject * = NULL );
87 virtual ~QwtPlotRenderer();
88
89 void setDiscardFlag( DiscardFlag flag, bool on = true );
90 bool testDiscardFlag( DiscardFlag flag ) const;
91
92 void setDiscardFlags( DiscardFlags flags );
93 DiscardFlags discardFlags() const;
94
95 void setLayoutFlag( LayoutFlag flag, bool on = true );
96 bool testLayoutFlag( LayoutFlag flag ) const;
97
98 void setLayoutFlags( LayoutFlags flags );
99 LayoutFlags layoutFlags() const;
100
101 void renderDocument( QwtPlot *, const QString &format,
102 const QSizeF &sizeMM, int resolution = 85 );
103
104 void renderDocument( QwtPlot *,
105 const QString &title, const QString &format,
106 const QSizeF &sizeMM, int resolution = 85 );
107
108#ifndef QWT_NO_SVG
109#ifdef QT_SVG_LIB
110#if QT_VERSION >= 0x040500
111 void renderTo( QwtPlot *, QSvgGenerator & ) const;
112#endif
113#endif
114#endif
115
116#ifndef QT_NO_PRINTER
117 void renderTo( QwtPlot *, QPrinter & ) const;
118#endif
119
120 void renderTo( QwtPlot *, QPaintDevice &p ) const;
121
122 virtual void render( QwtPlot *,
123 QPainter *, const QRectF &rect ) const;
124
125 virtual void renderLegendItem( const QwtPlot *,
126 QPainter *, const QWidget *, const QRectF & ) const;
127
128 virtual void renderTitle( const QwtPlot *,
129 QPainter *, const QRectF & ) const;
130
131 virtual void renderScale( const QwtPlot *, QPainter *,
132 int axisId, int startDist, int endDist,
133 int baseDist, const QRectF & ) const;
134
135 virtual void renderCanvas( const QwtPlot *,
136 QPainter *, const QRectF &canvasRect,
137 const QwtScaleMap* maps ) const;
138
139 virtual void renderLegend(
140 const QwtPlot *, QPainter *, const QRectF & ) const;
141
142protected:
143 void buildCanvasMaps( const QwtPlot *,
144 const QRectF &, QwtScaleMap maps[] ) const;
145
146private:
147 class PrivateData;
148 PrivateData *d_data;
149};
150
151Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRenderer::DiscardFlags )
152Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRenderer::LayoutFlags )
153
154#endif
Note: See TracBrowser for help on using the repository browser.