NCL Composer  0.1.5
 All Classes Functions Variables Pages
qnlygraphicsgrid.cpp
1 #include "qnlygraphicsgrid.h"
2 
3 QnlyGraphicsGrid::QnlyGraphicsGrid(QGraphicsItem* parent, QGraphicsScene* scene)
4  : QGraphicsRectItem(parent, scene)
5 {
6 
7 }
8 
9 QnlyGraphicsGrid::~QnlyGraphicsGrid()
10 {
11 
12 }
13 
14 void QnlyGraphicsGrid::setStep(qreal step)
15 {
16  this->step = step;
17 }
18 
19 qreal QnlyGraphicsGrid::getStep()
20 {
21  return step;
22 }
23 
24 void QnlyGraphicsGrid::setPen(QPen pen)
25 {
26  this->pen = pen;
27 }
28 
29 QPen QnlyGraphicsGrid::getPen()
30 {
31  return pen;
32 }
33 
34 void QnlyGraphicsGrid::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
35 {
36  painter->setPen(pen);
37 
38  QRectF r = rect();
39 
40  int w = 0;
41 
42  while (w < r.width())
43  {
44  painter->drawLine(w,0,w,r.height());
45  w += step;
46  }
47 
48  int h = 0;
49 
50  while (h < r.height())
51  {
52  painter->drawLine(0,h,r.width(),h);
53  h += step;
54  }
55 }