GobChartsWidget  1.0
gobchartsgrid.h
1 /* Copyright (C) 2012 by William Hallatt.
2  *
3  * This file forms part of the "GobChartsWidget" library.
4  *
5  * This library is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have downloaded a copy of the GNU General Public License
16  * (GNUGPL.txt) and GNU Lesser General Public License (GNULGPL.txt)
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * The official website for this project is www.goblincoding.com and,
20  * although not compulsory, it would be appreciated if all works of whatever
21  * nature referring to or using this library include a reference to this site.
22  */
23 
24 #ifndef GOBCHARTSGRID_H
25 #define GOBCHARTSGRID_H
26 
27 #include <QList>
28 #include <QPen>
29 #include "utils/gobchartsnocopy.h"
30 
31 class QGraphicsLineItem;
32 class QGraphicsScene;
33 
35 
40 class GobChartsGrid : public QObject,
41  public GobChartsNoCopy
42 {
43  Q_OBJECT
44 
45 public:
47  GobChartsGrid( QObject *parent = 0 );
48 
50  virtual ~GobChartsGrid();
51 
54  void addGridToScene( QGraphicsScene *scene );
55 
58  void removeGridFromScene( QGraphicsScene *scene );
59 
63  void constructGrid();
64 
67  void setGridRectF( const QRectF &rect );
68 
71  void setGridLineStyle( Qt::PenStyle style );
72 
75  void setHorizontalGridLines( bool set, int number );
76 
79  void setVerticalGridLines( bool set, int number );
80 
82  void setGridColour( QColor colour );
83 
85  qreal gridWidth() const;
86 
89  void setDebugLoggingOn( bool logging );
90 
91 signals:
95  void lastDebugLogMsg( QString );
96 
97 private:
98  QList< QGraphicsLineItem* > m_gridLines;
99  QRectF m_rectF;
100  QPen m_gridPen;
101  QPen m_axesPen;
102  int m_nrHorizontalLines;
103  int m_nrVerticalLines;
104  bool m_showHorizontalGrid;
105  bool m_showVerticalGrid;
106  bool m_loggingOn;
107 };
108 
109 #endif // GOBCHARTSGRID_H