qwt_plot_item.h 3.55 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 23 24 25 26 27 28 29 30 31 32 33
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the Qwt License, Version 1.0
 *****************************************************************************/

#ifndef QWT_PLOT_ITEM_H
#define QWT_PLOT_ITEM_H

#include "qwt_global.h"
#include "qwt_legend_itemmanager.h"
#include "qwt_text.h"
#include "qwt_double_rect.h"

class QString;
class QRect;
class QPainter;
class QWidget;
class QwtPlot;
class QwtLegend;
class QwtScaleMap;
class QwtScaleDiv;

/*!
  \brief Base class for items on the plot canvas
*/

class QWT_EXPORT QwtPlotItem: public QwtLegendItemManager
{
public:
34
    enum RttiValues {
pixhawk's avatar
pixhawk committed
35 36 37 38 39 40 41 42 43 44 45 46 47
        Rtti_PlotItem = 0,

        Rtti_PlotGrid,
        Rtti_PlotScale,
        Rtti_PlotMarker,
        Rtti_PlotCurve,
        Rtti_PlotHistogram,
        Rtti_PlotSpectrogram,
        Rtti_PlotSVG,

        Rtti_PlotUserItem = 1000
    };

48
    enum ItemAttribute {
pixhawk's avatar
pixhawk committed
49 50 51 52 53
        Legend = 1,
        AutoScale = 2
    };

#if QT_VERSION >= 0x040000
54
    enum RenderHint {
pixhawk's avatar
pixhawk committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
        RenderAntialiased = 1
    };
#endif

    explicit QwtPlotItem(const QwtText &title = QwtText());
    virtual ~QwtPlotItem();

    void attach(QwtPlot *plot);

    /*!
       \brief This method detaches a QwtPlotItem from any QwtPlot it has been
              associated with.

       detach() is equivalent to calling attach( NULL )
       \sa attach( QwtPlot* plot )
    */
71 72 73
    void detach() {
        attach(NULL);
    }
pixhawk's avatar
pixhawk committed
74 75

    QwtPlot *plot() const;
76

pixhawk's avatar
pixhawk committed
77 78 79 80 81 82 83 84 85 86 87 88 89 90
    void setTitle(const QString &title);
    void setTitle(const QwtText &title);
    const QwtText &title() const;

    virtual int rtti() const;

    void setItemAttribute(ItemAttribute, bool on = true);
    bool testItemAttribute(ItemAttribute) const;

#if QT_VERSION >= 0x040000
    void setRenderHint(RenderHint, bool on = true);
    bool testRenderHint(RenderHint) const;
#endif

91
    double z() const;
pixhawk's avatar
pixhawk committed
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
    void setZ(double z);

    void show();
    void hide();
    virtual void setVisible(bool);
    bool isVisible () const;

    void setAxis(int xAxis, int yAxis);

    void setXAxis(int axis);
    int xAxis() const;

    void setYAxis(int axis);
    int yAxis() const;

    virtual void itemChanged();

    /*!
      \brief Draw the item

      \param painter Painter
      \param xMap Maps x-values into pixel coordinates.
      \param yMap Maps y-values into pixel coordinates.
      \param canvasRect Contents rect of the canvas in painter coordinates
    */
117 118 119
    virtual void draw(QPainter *painter,
                      const QwtScaleMap &xMap, const QwtScaleMap &yMap,
                      const QRect &canvasRect) const = 0;
pixhawk's avatar
pixhawk committed
120 121 122 123 124

    virtual QwtDoubleRect boundingRect() const;

    virtual void updateLegend(QwtLegend *) const;
    virtual void updateScaleDiv(const QwtScaleDiv&,
125
                                const QwtScaleDiv&);
pixhawk's avatar
pixhawk committed
126 127 128 129 130

    virtual QWidget *legendItem() const;

    QwtDoubleRect scaleRect(const QwtScaleMap &, const QwtScaleMap &) const;
    QRect paintRect(const QwtScaleMap &, const QwtScaleMap &) const;
131 132 133

    QRect transform(const QwtScaleMap &, const QwtScaleMap &,
                    const QwtDoubleRect&) const;
pixhawk's avatar
pixhawk committed
134
    QwtDoubleRect invTransform(const QwtScaleMap &, const QwtScaleMap &,
135
                               const QRect&) const;
pixhawk's avatar
pixhawk committed
136 137 138 139 140 141 142 143 144

private:
    // Disabled copy constructor and operator=
    QwtPlotItem( const QwtPlotItem & );
    QwtPlotItem &operator=( const QwtPlotItem & );

    class PrivateData;
    PrivateData *d_data;
};
145

pixhawk's avatar
pixhawk committed
146
#endif