qwt_plot_grid.h 2.38 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
 * 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_GRID_H
#define QWT_PLOT_GRID_H

#include "qwt_global.h"
#include "qwt_plot_item.h"
#include "qwt_scale_div.h"

class QPainter;
class QPen;
class QwtScaleMap;
class QwtScaleDiv;

/*!
  \brief A class which draws a coordinate grid

  The QwtPlotGrid class can be used to draw a coordinate grid.
  A coordinate grid consists of major and minor vertical
Bryant's avatar
Bryant committed
27
  and horizontal grid lines. The locations of the grid lines
pixhawk's avatar
pixhawk committed
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  are determined by the X and Y scale divisions which can
  be assigned with setXDiv() and setYDiv().
  The draw() member draws the grid within a bounding
  rectangle.
*/

class QWT_EXPORT QwtPlotGrid: public QwtPlotItem
{
public:
    explicit QwtPlotGrid();
    virtual ~QwtPlotGrid();

    virtual int rtti() const;

Bryant's avatar
Bryant committed
42
    void enableX( bool tf );
pixhawk's avatar
pixhawk committed
43
44
    bool xEnabled() const;

Bryant's avatar
Bryant committed
45
    void enableY( bool tf );
pixhawk's avatar
pixhawk committed
46
47
    bool yEnabled() const;

Bryant's avatar
Bryant committed
48
    void enableXMin( bool tf );
pixhawk's avatar
pixhawk committed
49
50
    bool xMinEnabled() const;

Bryant's avatar
Bryant committed
51
    void enableYMin( bool tf );
pixhawk's avatar
pixhawk committed
52
53
    bool yMinEnabled() const;

Bryant's avatar
Bryant committed
54
    void setXDiv( const QwtScaleDiv &sx );
pixhawk's avatar
pixhawk committed
55
56
    const QwtScaleDiv &xScaleDiv() const;

Bryant's avatar
Bryant committed
57
    void setYDiv( const QwtScaleDiv &sy );
pixhawk's avatar
pixhawk committed
58
59
    const QwtScaleDiv &yScaleDiv() const;

Bryant's avatar
Bryant committed
60
61
    void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
    void setPen( const QPen & );
pixhawk's avatar
pixhawk committed
62

Bryant's avatar
Bryant committed
63
64
65
    void setMajorPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
    void setMajorPen( const QPen & );
    const QPen& majorPen() const;
pixhawk's avatar
pixhawk committed
66

Bryant's avatar
Bryant committed
67
68
69
    void setMinorPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
    void setMinorPen( const QPen &p );
    const QPen& minorPen() const;
pixhawk's avatar
pixhawk committed
70

Bryant's avatar
Bryant committed
71
72
73
    virtual void draw( QPainter *p,
        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
        const QRectF &rect ) const;
pixhawk's avatar
pixhawk committed
74

Bryant's avatar
Bryant committed
75
76
    virtual void updateScaleDiv( 
        const QwtScaleDiv &xMap, const QwtScaleDiv &yMap );
pixhawk's avatar
pixhawk committed
77
78

private:
Bryant's avatar
Bryant committed
79
80
81
    void drawLines( QPainter *painter, const QRectF &,
        Qt::Orientation orientation, const QwtScaleMap &,
        const QList<double> & ) const;
pixhawk's avatar
pixhawk committed
82
83
84
85
86
87

    class PrivateData;
    PrivateData *d_data;
};

#endif