Qwt User's Guide  6.1.1
 All Classes Functions Variables Typedefs Enumerations Enumerator Pages
Public Types | Public Member Functions | List of all members
QwtPlotRenderer Class Reference

Renderer for exporting a plot to a document, a printer or anything else, that is supported by QPainter/QPaintDevice. More...

#include <qwt_plot_renderer.h>

Inheritance diagram for QwtPlotRenderer:
Inheritance graph
[legend]

Public Types

enum  DiscardFlag {
  DiscardNone = 0x00, DiscardBackground = 0x01, DiscardTitle = 0x02, DiscardLegend = 0x04,
  DiscardCanvasBackground = 0x08, DiscardFooter = 0x10, DiscardCanvasFrame = 0x20
}
 Disard flags. More...
 
enum  LayoutFlag { DefaultLayout = 0x00, FrameWithScales = 0x01 }
 Layout flags. More...
 
typedef QFlags< DiscardFlagDiscardFlags
 Disard flags.
 
typedef QFlags< LayoutFlagLayoutFlags
 Layout flags.
 

Public Member Functions

 QwtPlotRenderer (QObject *=NULL)
 
virtual ~QwtPlotRenderer ()
 Destructor.
 
void setDiscardFlag (DiscardFlag flag, bool on=true)
 
bool testDiscardFlag (DiscardFlag flag) const
 
void setDiscardFlags (DiscardFlags flags)
 
DiscardFlags discardFlags () const
 
void setLayoutFlag (LayoutFlag flag, bool on=true)
 
bool testLayoutFlag (LayoutFlag flag) const
 
void setLayoutFlags (LayoutFlags flags)
 
LayoutFlags layoutFlags () const
 
void renderDocument (QwtPlot *, const QString &fileName, const QSizeF &sizeMM, int resolution=85)
 
void renderDocument (QwtPlot *, const QString &fileName, const QString &format, const QSizeF &sizeMM, int resolution=85)
 
void renderTo (QwtPlot *, QPrinter &) const
 Render the plot to a QPrinter. More...
 
void renderTo (QwtPlot *, QPaintDevice &p) const
 Render the plot to a QPaintDevice. More...
 
virtual void render (QwtPlot *, QPainter *, const QRectF &rect) const
 
virtual void renderTitle (const QwtPlot *, QPainter *, const QRectF &) const
 
virtual void renderFooter (const QwtPlot *, QPainter *, const QRectF &) const
 
virtual void renderScale (const QwtPlot *, QPainter *, int axisId, int startDist, int endDist, int baseDist, const QRectF &) const
 Paint a scale into a given rectangle. Paint the scale into a given rectangle. More...
 
virtual void renderCanvas (const QwtPlot *, QPainter *, const QRectF &canvasRect, const QwtScaleMap *maps) const
 
virtual void renderLegend (const QwtPlot *, QPainter *, const QRectF &) const
 
bool exportTo (QwtPlot *, const QString &documentName, const QSizeF &sizeMM=QSizeF(300, 200), int resolution=85)
 Execute a file dialog and render the plot to the selected file. More...
 

Detailed Description

Renderer for exporting a plot to a document, a printer or anything else, that is supported by QPainter/QPaintDevice.

Member Enumeration Documentation

Disard flags.

Enumerator
DiscardNone 

Render all components of the plot.

DiscardBackground 

Don't render the background of the plot.

DiscardTitle 

Don't render the title of the plot.

DiscardLegend 

Don't render the legend of the plot.

DiscardCanvasBackground 

Don't render the background of the canvas.

DiscardFooter 

Don't render the footer of the plot.

DiscardCanvasFrame 

Don't render the frame of the canvas

Note
This flag has no effect when using style sheets, where the frame is part of the background

Layout flags.

See Also
setLayoutFlag(), testLayoutFlag()
Enumerator
DefaultLayout 

Use the default layout as on screen.

FrameWithScales 

Instead of the scales a box is painted around the plot canvas, where the scale ticks are aligned to.

Constructor & Destructor Documentation

QwtPlotRenderer::QwtPlotRenderer ( QObject *  parent = NULL)
explicit

Constructor

Parameters
parentParent object

Member Function Documentation

QwtPlotRenderer::DiscardFlags QwtPlotRenderer::discardFlags ( ) const
Returns
Flags, indicating what to discard from rendering
See Also
DiscardFlag, setDiscardFlags(), setDiscardFlag(), testDiscardFlag()
bool QwtPlotRenderer::exportTo ( QwtPlot plot,
const QString &  documentName,
const QSizeF &  sizeMM = QSizeF( 300, 200 ),
int  resolution = 85 
)

Execute a file dialog and render the plot to the selected file.

Parameters
plotPlot widget
documentNameDefault document name
sizeMMSize for the document in millimeters.
resolutionResolution in dots per Inch (dpi)
Returns
True, when exporting was successful
See Also
renderDocument()
QwtPlotRenderer::LayoutFlags QwtPlotRenderer::layoutFlags ( ) const
void QwtPlotRenderer::render ( QwtPlot plot,
QPainter *  painter,
const QRectF &  plotRect 
) const
virtual

Paint the contents of a QwtPlot instance into a given rectangle.

Parameters
plotPlot to be rendered
painterPainter
plotRectBounding rectangle
See Also
renderDocument(), renderTo(), QwtPainter::setRoundingAlignment()
void QwtPlotRenderer::renderCanvas ( const QwtPlot plot,
QPainter *  painter,
const QRectF &  canvasRect,
const QwtScaleMap map 
) const
virtual

Render the canvas into a given rectangle.

Parameters
plotPlot widget
painterPainter
mapMaps mapping between plot and paint device coordinates
canvasRectCanvas rectangle
void QwtPlotRenderer::renderDocument ( QwtPlot plot,
const QString &  fileName,
const QSizeF &  sizeMM,
int  resolution = 85 
)

Render a plot to a file

The format of the document will be auto-detected from the suffix of the file name.

Parameters
plotPlot widget
fileNamePath of the file, where the document will be stored
sizeMMSize for the document in millimeters.
resolutionResolution in dots per Inch (dpi)
void QwtPlotRenderer::renderDocument ( QwtPlot plot,
const QString &  fileName,
const QString &  format,
const QSizeF &  sizeMM,
int  resolution = 85 
)

Render a plot to a file

Supported formats are:

  • pdf
    Portable Document Format PDF
  • ps
    Postcript
  • svg
    Scalable Vector Graphics SVG
  • all image formats supported by Qt
    see QImageWriter::supportedImageFormats()

Scalable vector graphic formats like PDF or SVG are superior to raster graphics formats.

Parameters
plotPlot widget
fileNamePath of the file, where the document will be stored
formatFormat for the document
sizeMMSize for the document in millimeters.
resolutionResolution in dots per Inch (dpi)
See Also
renderTo(), render(), QwtPainter::setRoundingAlignment()
void QwtPlotRenderer::renderFooter ( const QwtPlot plot,
QPainter *  painter,
const QRectF &  rect 
) const
virtual

Render the footer into a given rectangle.

Parameters
plotPlot widget
painterPainter
rectBounding rectangle
void QwtPlotRenderer::renderLegend ( const QwtPlot plot,
QPainter *  painter,
const QRectF &  rect 
) const
virtual

Render the legend into a given rectangle.

Parameters
plotPlot widget
painterPainter
rectBounding rectangle
void QwtPlotRenderer::renderScale ( const QwtPlot plot,
QPainter *  painter,
int  axisId,
int  startDist,
int  endDist,
int  baseDist,
const QRectF &  rect 
) const
virtual

Paint a scale into a given rectangle. Paint the scale into a given rectangle.

Parameters
plotPlot widget
painterPainter
axisIdAxis
startDistStart border distance
endDistEnd border distance
baseDistBase distance
rectBounding rectangle
void QwtPlotRenderer::renderTitle ( const QwtPlot plot,
QPainter *  painter,
const QRectF &  rect 
) const
virtual

Render the title into a given rectangle.

Parameters
plotPlot widget
painterPainter
rectBounding rectangle
void QwtPlotRenderer::renderTo ( QwtPlot plot,
QPrinter &  printer 
) const

Render the plot to a QPrinter.

This function renders the contents of a QwtPlot instance to QPaintDevice object. The size is derived from the printer metrics.

Parameters
plotPlot to be rendered
printerPrinter to paint on
See Also
renderDocument(), render(), QwtPainter::setRoundingAlignment()
void QwtPlotRenderer::renderTo ( QwtPlot plot,
QPaintDevice &  paintDevice 
) const

Render the plot to a QPaintDevice.

This function renders the contents of a QwtPlot instance to QPaintDevice object. The target rectangle is derived from its device metrics.

Parameters
plotPlot to be rendered
paintDevicedevice to paint on, f.e a QImage
See Also
renderDocument(), render(), QwtPainter::setRoundingAlignment()
void QwtPlotRenderer::setDiscardFlag ( DiscardFlag  flag,
bool  on = true 
)

Change a flag, indicating what to discard from rendering

Parameters
flagFlag to change
onOn/Off
See Also
DiscardFlag, testDiscardFlag(), setDiscardFlags(), discardFlags()
void QwtPlotRenderer::setDiscardFlags ( DiscardFlags  flags)

Set the flags, indicating what to discard from rendering

Parameters
flagsFlags
See Also
DiscardFlag, setDiscardFlag(), testDiscardFlag(), discardFlags()
void QwtPlotRenderer::setLayoutFlag ( LayoutFlag  flag,
bool  on = true 
)

Change a layout flag

Parameters
flagFlag to change
onOn/Off
See Also
LayoutFlag, testLayoutFlag(), setLayoutFlags(), layoutFlags()
void QwtPlotRenderer::setLayoutFlags ( LayoutFlags  flags)

Set the layout flags

Parameters
flagsFlags
See Also
LayoutFlag, setLayoutFlag(), testLayoutFlag(), layoutFlags()
bool QwtPlotRenderer::testDiscardFlag ( DiscardFlag  flag) const
Returns
True, if flag is enabled.
Parameters
flagFlag to be tested
See Also
DiscardFlag, setDiscardFlag(), setDiscardFlags(), discardFlags()
bool QwtPlotRenderer::testLayoutFlag ( LayoutFlag  flag) const
Returns
True, if flag is enabled.
Parameters
flagFlag to be tested
See Also
LayoutFlag, setLayoutFlag(), setLayoutFlags(), layoutFlags()