-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinalgraph.cpp
More file actions
62 lines (57 loc) · 1.29 KB
/
finalgraph.cpp
File metadata and controls
62 lines (57 loc) · 1.29 KB
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
#include "finalgraph.h"
#include <QPainter>
/*
Coded By: Zander Louie
Function: Default Graph Constructor
Params: height and (x,y) coord for upper left corner
Desc: Draws a white rectangle
Returns: Graph
*/
FinalGraph::FinalGraph(int height, int x, int y, QColor)
{
x_ = x;
y_ = y;
height_ = height;
QColor c(Qt::GlobalColor::white);
color_ = Qt::GlobalColor::blue;
}
/*
Coded By: Zander Louie
Function: BoundingRect
Params: none
Desc: Sets Bounding Rect for graph object
Returns: QRectF
*/
QRectF FinalGraph::boundingRect() const
{
return QRectF(x_,y_, width_, height_);
}
/*
Coded By: Zander Louie
Function: shape
Params: none
Desc: sets graph as rectangle
Returns: QPainterPath
*/
QPainterPath FinalGraph::shape() const
{
QPainterPath path;
path.addRect(x_,y_,width_,height_);
return path;
}
/*
Coded By: Zander Louie
Function: Paint
Params: QPainter, QStyleOptionGraphicsItem, QWidget
Desc: allows graph to be drawn
Returns: void
*/
void FinalGraph::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(widget)
QBrush b = painter->brush();
painter->setBrush(QBrush(color_));
//painter->setBrush(Qt::NoBrush);
painter->drawRect(QRect(this->x_, this->y_, this-> width_, this-> height_));
painter->setBrush(b);
}