qwt_plot_canvas.h 2.9 KB
Newer Older
pixhawk's avatar
pixhawk committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 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 108 109 110 111 112 113 114 115 116 117
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
 * Qwt Widget Library
 * Copyright (C) 1997   Josef Wilgen
 * Copyright (C) 2002   Uwe Rathmann
 * 
 * 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;

/*!
  Canvas of a QwtPlot. 
  \sa QwtPlot 
*/
class QWT_EXPORT QwtPlotCanvas : public QFrame
{
    Q_OBJECT

public:

    /*!
      \brief Paint attributes
 
      - PaintCached\n
        Paint double buffered and reuse the content of the pixmap buffer 
        for some spontaneous repaints that happen when a plot gets unhidden, 
        deiconified or changes the focus.
        Disabling the cache will improve the performance for
        incremental paints (using QwtPlotCurve::draw). 

      - PaintPacked\n
        Suppress system background repaints and paint it together with 
        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()
     */
    enum PaintAttribute
    {
        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()
    */

    enum FocusIndicator
    {
        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);

private:    
    void setSystemBackground(bool);

    class PrivateData;
    PrivateData *d_data;
};

#endif