qwt_plot_canvas.h 2.88 KB
Newer Older
pixhawk's avatar
pixhawk committed
1 2 3 4
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
 * Qwt Widget Library
 * Copyright (C) 1997   Josef Wilgen
 * Copyright (C) 2002   Uwe Rathmann
5
 *
pixhawk's avatar
pixhawk committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the Qwt License, Version 1.0
 *****************************************************************************/

// vim: expandtab

#ifndef QWT_PLOT_CANVAS_H
#define QWT_PLOT_CANVAS_H

#include <qframe.h>
#include <qpen.h>
#include "qwt_global.h"

class QwtPlot;
class QPixmap;

/*!
23 24
  Canvas of a QwtPlot.
  \sa QwtPlot
pixhawk's avatar
pixhawk committed
25 26 27 28 29 30 31 32 33
*/
class QWT_EXPORT QwtPlotCanvas : public QFrame
{
    Q_OBJECT

public:

    /*!
      \brief Paint attributes
34

pixhawk's avatar
pixhawk committed
35
      - PaintCached\n
36 37
        Paint double buffered and reuse the content of the pixmap buffer
        for some spontaneous repaints that happen when a plot gets unhidden,
pixhawk's avatar
pixhawk committed
38 39
        deiconified or changes the focus.
        Disabling the cache will improve the performance for
40
        incremental paints (using QwtPlotCurve::draw).
pixhawk's avatar
pixhawk committed
41 42

      - PaintPacked\n
43
        Suppress system background repaints and paint it together with
pixhawk's avatar
pixhawk committed
44 45 46 47 48 49 50 51 52
        the canvas contents.
        Painting packed might avoid flickering for expensive repaints,
        when there is a notable gap between painting the background
        and the plot contents.

      The default setting enables PaintCached and PaintPacked

      \sa setPaintAttribute(), testPaintAttribute(), paintCache()
     */
53
    enum PaintAttribute {
pixhawk's avatar
pixhawk committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
        PaintCached = 1,
        PaintPacked = 2
    };

    /*!
      \brief Focus indicator

      - NoFocusIndicator\n
        Don't paint a focus indicator

      - CanvasFocusIndicator\n
        The focus is related to the complete canvas.
        Paint the focus indicator using paintFocus()

      - ItemFocusIndicator\n
        The focus is related to an item (curve, point, ...) on
        the canvas. It is up to the application to display a
        focus indication using f.e. highlighting.

      \sa setFocusIndicator(), focusIndicator(), paintFocus()
    */

76
    enum FocusIndicator {
pixhawk's avatar
pixhawk committed
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
        NoFocusIndicator,
        CanvasFocusIndicator,
        ItemFocusIndicator
    };

    explicit QwtPlotCanvas(QwtPlot *);
    virtual ~QwtPlotCanvas();

    QwtPlot *plot();
    const QwtPlot *plot() const;

    void setFocusIndicator(FocusIndicator);
    FocusIndicator focusIndicator() const;

    void setPaintAttribute(PaintAttribute, bool on = true);
    bool testPaintAttribute(PaintAttribute) const;

    QPixmap *paintCache();
    const QPixmap *paintCache() const;
    void invalidatePaintCache();

protected:
    virtual void hideEvent(QHideEvent *);

    virtual void paintEvent(QPaintEvent *);

    virtual void drawContents(QPainter *);
    virtual void drawFocusIndicator(QPainter *);

    void drawCanvas(QPainter *painter = NULL);

108
private:
pixhawk's avatar
pixhawk committed
109 110 111 112 113 114 115
    void setSystemBackground(bool);

    class PrivateData;
    PrivateData *d_data;
};

#endif